Commands wont work - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Commands wont work (
/showthread.php?tid=139636)
Commands wont work -
WardenCS - 05.04.2010
Hello,i tried to make an command with you can promote any user if you are RCON admin,but if i write /promote 0,it wont work,nothing wont show up
heres the code
Код:
if(strcmp(cmdtext, "/promote", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new tmp[32];
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /promote [playerid/PartOfName]");
return 1;
}
new string[256];
new para1;
para1 = strval(tmp);
new giveplayer[MAX_PLAYER_NAME];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(para1, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
if(IsPlayerConnected(para1))
{
if(IsPlayerAdmin(playerid))
{
format(string, sizeof(string), " You have promoted %s to Principal.", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[playerid][fLeader] = 1;
SetPlayerSkin(playerid,295);
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command(leaders only)!");
}
}
return 1;
}
Re: Commands wont work -
¤Adas¤ - 05.04.2010
You have forgotten "tmp = strtok(...)" or something like that, I don't know what functions do you use
Re: Commands wont work -
WardenCS - 05.04.2010
tried something,got 1 error
Код:
C:\Documents and Settings\xx\Desktop\Uus kaust (5)\gamemodes\sadsa.pwn(876) : error 029: invalid expression, assumed zero
Код:
if(strcmp(cmd, "/promote", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new giveplayer[MAX_PLAYER_NAME];
new tmp[256];
new idx;
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /promote [playerid/PartOfName]");
return 1;
}
new para1;
para1 = strval(tmp);
if(IsPlayerConnected(para1))
{
if(IsPlayerAdmin(playerid))
{
new string[256];
format(string, sizeof(string), " You have promoted %s to Principal.", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[playerid][fLeader] = 1;
SetPlayerSkin(playerid,295);
}
}
else
{
SendClientMessage(para1, COLOR_YELLOW, "Error: You are not connected yet!!");
}
line 876 else
{
SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
}
}
return 1;
}
EDIT:FIXED!