/setteam cmd
#1

hey guys i hope you all fine today , i'm just asking for some help in this command

Quote:

if (strcmp("/setusa", cmdtext, true, 10) == 0||strcmp("/SETUSA", cmdtext, true, 10) == 0)
{
if (IsPlayerAdmin(playerid))
{
new id, pname1[24], string[250];
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid Player");
SetPlayerTeam(id,0);
SetPlayerColor(id,COLOR_BLUETEAM);
gTeam[id] = TEAM_USA;
GetPlayerName(id, pname1, 24);
format(string, 250, "You Set %s (%d) Team To {0x0000FF}USA", pname1, id);
}
return 1;
}

yeah the problem is when i use it it says

Quote:

SERVER: Unknown Command

i hope you guys help me

and if there someone have a better cmd i will be thankful for helping me
Reply
#2

Please use a [ pawn] [/ pawn] (without space) to show your code here.
Reply
#3

pawn Код:
if (strcmp("/setusa", cmdtext, true, 10) == 0||strcmp("/SETUSA", cmdtext, true, 10) == 0) // This is useless commands are not case insensetive.
{
    if(IsPlayerAdmin(playerid))
    {
        new id, pname1[24], string[250];
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid Player");
        SetPlayerTeam(id,0);
        SetPlayerColor(id,COLOR_BLUETEAM);
        gTeam[id] = TEAM_USA;
        GetPlayerName(id, pname1, 24);
        format(string,sizeof(string), "You've set %s(%d) to Team USA.", pname1, id);
    } else { SendClientMessage(playerid,-1,"No authorization."); }
       return 1;
}
Try this.
Make sure you remove ||strcmp("/SETUSA", cmdtext, true, 10) == 0
Reply
#4

That's why the case parameter is set to true so "setusa", "SETUSA" are the same. id will always be 0 and string 250? The message is not even 60 lenght.

pawn Код:
if (!strcmp("/setusa", cmdtext, true, 7))
{
    if (!IsPlayerAdmin(playerid)) return 1;

    new
        id = strval(cmdtext[8]);
   
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Invalid Player");

    SetPlayerTeam(id, 0);
    SetPlayerColor(id, COLOR_BLUETEAM);
    gTeam[id] = TEAM_USA;

    new
        pname1[MAX_PLAYER_NAME],
        string[58];
   
    GetPlayerName(id, pname1, MAX_PLAYER_NAME);
    format(string, sizeof (string), "You Set %s (%d) Team To {0x0000FF}USA", pname1, id);
    return 1;
}
If it displays the unknown message again after using the above code, load crashdetect plugin.
Reply
#5

ok Thank You its working now ^^

but another question

how do i set team for another player not to my self ?
Reply
#6

I am using ZCMD and sscanf:

Код:
CMD:setusa(playerid, params)
{
    if (IsPlayerAdmin(playerid))

    new id;
    if(sscanf(params, "u", id))
    if (IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Invalid Player");

    SetPlayerTeam(id, 0);
    SetPlayerColor(id, COLOR_BLUETEAM);
    gTeam[id] = TEAM_USA;

    new
        pname1[MAX_PLAYER_NAME], 
        string[58];
    
    GetPlayerName(id, pname1, MAX_PLAYER_NAME);
    format(string, sizeof (string), "You Set %s (%d) Team To {0x0000FF}USA", pname1, id);
    return 1;
}
Srry for any mistakes as i am on mobile.
And ye, u made it if the player is not admin the it will work. And u checked if the player is only then it will send message that the player is not online
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)