/megaphone Chat Problem

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Guten Tag die Damen und Herren ^^


    Ich habe wiedermal Probleme mit meinem Script, diesmal mit dem Megaphone System. Wenn ich, nach dem ich Duty gegangen bin, /m eingebe und dazu einen Text, wird dieser angezeigt. Ich möchte das aber so haben, dass dieser Text nur angezeigt wird, wenn man in einem Fahrzeug ist. Ich habe schon einen versuch getan, dies so festzulegen, aber irgendwie ging das trotzdem nicht. Das ist das, was ich das letzte mal dort geändert habe:



    if(strcmp(cmd, "/megaphone", true) == 0 || strcmp(cmd, "/m", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
    idx++;
    }
    new offset = idx;
    new result[64];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
    result[idx - offset] = cmdtext[idx];
    idx++;
    }
    result[idx - offset] = EOS;
    if(OnDuty[playerid]==0)
    {
    SendClientMessage(playerid, COLOR_GREY, "Du bist kein Beamter!");
    return 1;
    }
    if(!strlen(result))
    {
    SendClientMessage(playerid, COLOR_GRAD2, "Benutze: (/m)egaphone [megaphone chat]");
    return 1;
    }
    if(gTeam[playerid] == 2 || IsACop(playerid) || PlayerInfo[playerid][pMember] == 24||PlayerInfo[playerid][pLeader] == 24 || PlayerInfo[playerid][pMember] == 4||PlayerInfo[playerid][pLeader] == 4 || PlayerInfo[playerid][pMember] == 22||PlayerInfo[playerid][pLeader] == 22)
    {
    new modelid;
    new vehicleid;
    modelid = GetVehicleModel(vehicleid);
    if((modelid == 548) || (modelid == 425) || (modelid == 417) || (modelid == 497) || (modelid == 563) || (modelid == 416) || (modelid == 433) || (modelid == 523) || (modelid == 427) || (modelid == 490) || (modelid == 528) || (modelid == 407) || (modelid == 544) || (modelid == 596) || (modelid == 597) || (modelid == 598) || (modelid == 599) || (modelid == 432) || (modelid == 601) || (modelid == 472) || (modelid == 595) || (modelid == 430) || (modelid == 525))
    {
    if(PlayerInfo[playerid][pMember] == 1||PlayerInfo[playerid][pLeader] == 1)
    {
    new currank[64];
    if(PlayerInfo[playerid][pRank] == 1) { currank = "Polizeianwärter"; }
    else { currank = "Polizeianwärter"; }
    format(string, sizeof(string), "[%s %s: %s]", currank, sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    else if(PlayerInfo[playerid][pMember] == 2||PlayerInfo[playerid][pLeader] == 2)
    {
    format(string, sizeof(string), "[Officer %s:o< %s]", sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    if(PlayerInfo[playerid][pMember] == 3||PlayerInfo[playerid][pLeader] == 3)
    {
    new currank[64];
    if(PlayerInfo[playerid][pRank] == 1) { currank = "Schütze"; }
    else { currank = "Schütze"; }
    format(string, sizeof(string), "[%s %s: %s]", currank, sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    if(PlayerInfo[playerid][pMember] == 4||PlayerInfo[playerid][pLeader] == 4)
    {
    new currank[64];
    if(PlayerInfo[playerid][pRank] == 1) { currank = "Sanitätshelfer"; }
    else { currank = "Sanitätshelfer"; }
    format(string, sizeof(string), "[%s %s: %s]", currank, sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    if(PlayerInfo[playerid][pMember] == 22||PlayerInfo[playerid][pLeader] == 22)
    {
    new currank[64];
    if(PlayerInfo[playerid][pRank] == 1) { currank = "Feuerwehrmann"; }
    else { currank = "Feuerwehrmann"; }
    format(string, sizeof(string), "[%s %s: %s]", currank, sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    else if(PlayerInfo[playerid][pMember] == 21||PlayerInfo[playerid][pLeader] == 21)
    {
    format(string, sizeof(string), "[FBI Agent %s:o< %s]", sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    else if(PlayerInfo[playerid][pMember] == 24||PlayerInfo[playerid][pLeader] == 24)
    {
    format(string, sizeof(string), "[O-Amt %s:o< %s]", sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    printf("%s", string);
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD2, " Du musst bei der Polizei/FBI/Bundeswehr sein, um diesen Befehl benutzen zu können !");
    return 1;
    }
    }
    }
    return 1;
    }


    Ich hoffe ihr könnt mir helfen,


    Grüße, Tommi

  • if(strcmp(cmd, "/megaphone", true) == 0 || strcmp(cmd, "/m", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
    idx++;
    }
    new offset = idx;
    new result[64];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
    result[idx - offset] = cmdtext[idx];
    idx++;
    }
    result[idx - offset] = EOS;
    if(OnDuty[playerid]==0)
    {
    SendClientMessage(playerid, COLOR_GREY, "Du bist kein Beamter!");
    return 1;
    }
    if(!strlen(result))
    {
    SendClientMessage(playerid, COLOR_GRAD2, "Benutze: (/m)egaphone [megaphone chat]");
    return 1;
    }
    if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER && GetPlayerState(playerid)!=PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,COLOR_GRAD2,"Du bist in keinem Fahrzeug!");
    if(gTeam[playerid] == 2 || IsACop(playerid) || PlayerInfo[playerid][pMember] == 24||PlayerInfo[playerid][pLeader] == 24 || PlayerInfo[playerid][pMember] == 4||PlayerInfo[playerid][pLeader] == 4 || PlayerInfo[playerid][pMember] == 22||PlayerInfo[playerid][pLeader] == 22)
    {
    new modelid;
    new vehicleid;
    modelid = GetVehicleModel(vehicleid);
    if((modelid == 548) || (modelid == 425) || (modelid == 417) || (modelid == 497) || (modelid == 563) || (modelid == 416) || (modelid == 433) || (modelid == 523) || (modelid == 427) || (modelid == 490) || (modelid == 528) || (modelid == 407) || (modelid == 544) || (modelid == 596) || (modelid == 597) || (modelid == 598) || (modelid == 599) || (modelid == 432) || (modelid == 601) || (modelid == 472) || (modelid == 595) || (modelid == 430) || (modelid == 525))
    {
    if(PlayerInfo[playerid][pMember] == 1||PlayerInfo[playerid][pLeader] == 1)
    {
    new currank[64];
    if(PlayerInfo[playerid][pRank] == 1) { currank = "Polizeianwärter"; }
    else { currank = "Polizeianwärter"; }
    format(string, sizeof(string), "[%s %s: %s]", currank, sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    else if(PlayerInfo[playerid][pMember] == 2||PlayerInfo[playerid][pLeader] == 2)
    {
    format(string, sizeof(string), "[Officer %s:o< %s]", sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    if(PlayerInfo[playerid][pMember] == 3||PlayerInfo[playerid][pLeader] == 3)
    {
    new currank[64];
    if(PlayerInfo[playerid][pRank] == 1) { currank = "Schütze"; }
    else { currank = "Schütze"; }
    format(string, sizeof(string), "[%s %s: %s]", currank, sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    if(PlayerInfo[playerid][pMember] == 4||PlayerInfo[playerid][pLeader] == 4)
    {
    new currank[64];
    if(PlayerInfo[playerid][pRank] == 1) { currank = "Sanitätshelfer"; }
    else { currank = "Sanitätshelfer"; }
    format(string, sizeof(string), "[%s %s: %s]", currank, sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    if(PlayerInfo[playerid][pMember] == 22||PlayerInfo[playerid][pLeader] == 22)
    {
    new currank[64];
    if(PlayerInfo[playerid][pRank] == 1) { currank = "Feuerwehrmann"; }
    else { currank = "Feuerwehrmann"; }
    format(string, sizeof(string), "[%s %s: %s]", currank, sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    else if(PlayerInfo[playerid][pMember] == 21||PlayerInfo[playerid][pLeader] == 21)
    {
    format(string, sizeof(string), "[FBI Agent %s:o< %s]", sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    else if(PlayerInfo[playerid][pMember] == 24||PlayerInfo[playerid][pLeader] == 24)
    {
    format(string, sizeof(string), "[O-Amt %s:o< %s]", sendername, result);
    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
    }
    printf("%s", string);
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD2, " Du musst bei der Polizei/FBI/Bundeswehr sein, um diesen Befehl benutzen zu können !");
    return 1;
    }
    }
    }
    return 1;
    }

    The fact is, I am right. And if you think I'm wrong, you are wrong.