PDA

View Full Version : /setteam cmd


GGW
13/02/2014, 09:36 AM
hey guys i hope you all fine today , i'm just asking for some help in this command

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

SERVER: Unknown Command

i hope you guys help me :D

and if there someone have a better cmd i will be thankful for helping me :)

$Marco$
13/02/2014, 09:39 AM
Please use a [ pawn] [/ pawn] (without space) to show your code here.

Beckett
13/02/2014, 09:40 AM
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 = 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.
[I]Make sure you remove ||strcmp("/SETUSA", cmdtext, true, 10) == 0

Konstantinos
13/02/2014, 09:51 AM
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.


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.

GGW
13/02/2014, 10:00 AM
ok Thank You its working now ^^

but another question

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

UnknownOwner
13/02/2014, 10:17 AM
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