Commands problem -
Soumi - 19.03.2011
Hello , i got some problems with those two cmds
there is no errors or warnings , but their not working in Game
here's the code
First cmd :
PHP код:
if(!strcmp(cmd, "/setscore"))
{
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
new targetid, score, string[128];
if(sscanf(params, "uz", targetid,score)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid/partofname] [score]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected!");
else
{
SetPlayerScore(targetid, score);
format(string,sizeof(string),"an Admin has changed your Score to %s ", score);
SendClientMessage(targetid, 0xA10000AA, string);
}
}
return 1;
}
Second one
PHP код:
if(!strcmp(cmd, "/asay1"))
{
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
new text[128];
if(sscanf(params, "s[128]",text)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay [text]");
else
{
new string[128];
new pName[128];
GetPlayerName(playerid,pName,128);
format(string,sizeof string,"[ADMIN]%s: %s",pName,text);
SendClientMessageToAll(0xA10000AA,string);
}
}
return 1;
}
Re: Commands problem -
iJumbo - 19.03.2011
why
else
{
code
} ?? you dont need to put else ^^
Re: Commands problem -
bijoyekuza - 19.03.2011
Код:
if(!strcmp(cmd, "/setscore",true) == 0)
{
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
new targetid, score, string[128];
if(sscanf(params, "uz", targetid,score)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid/partofname] [score]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected!");
else
{
SetPlayerScore(targetid, score);
format(string,sizeof(string),"an Admin has changed your Score to %s ", score);
SendClientMessage(targetid, 0xA10000AA, string);
}
}
return 1;
}
Код:
if(!strcmp(cmd, "/asay1",true) == 0)
{
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
new text[128];
if(sscanf(params, "s[128]",text)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay [text]");
else
{
new string[128];
new pName[128];
GetPlayerName(playerid,pName,128);
format(string,sizeof string,"[ADMIN]%s: %s",pName,text);
SendClientMessageToAll(0xA10000AA,string);
}
}
return 1;
}
Re: Commands problem -
iJumbo - 19.03.2011
-.- you dont have 2 put else!!!!!!!!!
Re: Commands problem -
Roomeo - 19.03.2011
For first one Try this Not tested
pawn Код:
if(!strcmp(cmd, "/setscore"))
{
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
new targetid, score, string[128];
if(sscanf(params, "uz", targetid,score)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid/partofname] [score]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected!");
SetPlayerScore(targetid, score);
format(string,sizeof(string),"an Admin has changed your Score to %s ", score);
SendClientMessage(targetid, 0xA10000AA, string);
}
}
return 1;
}
Re: Commands problem -
bijoyekuza - 19.03.2011
Quote:
Originally Posted by [ISS]jumbo
-.- you dont have 2 put else!!!!!!!!!
|
+1
get rid of the elses
Код:
if(!strcmp(cmd, "/setscore"))
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
new targetid, score, string[128];
if(sscanf(params, "uz", targetid,score)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid/partofname] [score]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected!");
SetPlayerScore(targetid, score);
format(string,sizeof(string),"an Admin has changed your Score to %s ", score);
SendClientMessage(targetid, 0xA10000AA, string);
return 1;
}
Код:
if(!strcmp(cmd, "/asay1"))
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
new text[128];
if(sscanf(params, "s[128]",text)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay [text]");
new string[128];
new pName[128];
GetPlayerName(playerid,pName,128);
format(string,sizeof string,"[ADMIN]%s: %s",pName,text);
SendClientMessageToAll(0xA10000AA,string);
return 1;
}
Re : Commands problem -
Soumi - 19.03.2011
I Tryed all you told me to do.. But still not working...
For the /setscore , when i do /setscore 0 7 , my score changes to 55 and when i do /setscore 0 9 , nothing happens.
and for the /asay1 , still when i do /asay1 Hey , it shows /asay1 [text]
Can you please try to help me?
Re: Commands problem -
bijoyekuza - 19.03.2011
im kindof new to sscanf , so I you would make it with strtok what would be good .
but this should really fix the problem. but I know that in sscanf i = integer . why did you put there uz?
Re : Commands problem -
Soumi - 19.03.2011
I Put uz because , i made /setarmour and /sethealth and the 2 commands so i thought /setscore will work in the same way.
Re: Commands problem -
Rivera - 19.03.2011
and that's us problem. You have to put ui even for the setarmour and sethealth. uz is used only on some cmds like /ban etc... (not /kick)