Help please
#1

Hey guys, can someone tell me why this command doesn't work perfectly

It does work with setting the stats. But it's like when I only type this: /setstat
it says:
You have setted NAME his money to 0

WIthout I even filled in an ID or amount

Please help

pawn Код:
COMMAND:setstat(playerid,params[])
{
new stat[20],id,value,string[286];
if(adminlevel[playerid] <1) return SendClientMessage(playerid,COLOR_RED,"You're not allowed to do this");
if(sscanf(params,"usd",id,stat,value)) SendClientMessage(playerid, COLOR_RED, "HINT: /setstat [playerid] [stat] [amount]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected");
else

if(!strcmp(stat,"money",true))
{
money[id] = value;
format(string,sizeof(string),"Your money has been setted to %d by Admin %s",value,playername[playerid]);
SendClientMessage(id,COLOR_YELLOW,string);
format(string,sizeof(string),"You've setted %s's money to %d",playername[id],value);
SendClientMessage(id,COLOR_YELLOW,string);
}
else
if(!strcmp(stat,"age",true))
{
age[id] = value;
format(string,sizeof(string),"Your age has been setted to %d by Admin %s",value,playername[playerid]);
SendClientMessage(id,COLOR_YELLOW,string);
format(string,sizeof(string),"You've setted %s's age to %d",playername[id],value);
SendClientMessage(id,COLOR_YELLOW,string);
}
else
if(!strcmp(stat,"fishes",true))
{
fishes[id] = value;
format(string,sizeof(string),"Your fishes has been setted to %d by Admin %s",value,playername[playerid]);
SendClientMessage(id,COLOR_YELLOW,string);
format(string,sizeof(string),"You've setted %s's fishes to %d",playername[id],value);
SendClientMessage(id,COLOR_YELLOW,string);
}

else
SendClientMessage(playerid,COLOR_RED,"Invalid choice");
return 1;
}
Reply
#2

pawn Код:
if(sscanf(params,"us[20]d",id,stat,value)) SendClientMessage(playerid, COLOR_RED, "HINT: /setstat [playerid] [stat] [amount]");
It's probably giving you a console warning, of sscanf.
Reply
#3

Alright, The warning is fixed indeed.
But my other problem is still here : (
Reply
#4

You should try removing this "else" from here:
pawn Код:
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected");
else // here
I have a command similar to yours, but with x y z as paraments, and works. Even though it's a self-action, which doesn't needs a ID paraments. And it's not using sscanf.
Reply
#5

I already have that as you can see.. :P
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)