[unsolved] - very easy! (i think:P) - 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: [unsolved] - very easy! (i think:P) (
/showthread.php?tid=106726)
[unsolved] - very easy! (i think:P) -
PANNA - 05.11.2009
Код:
if(strcmp("/givescore",cmdtext,true,10) == 0)
{
if(IsPlayerAdmin(playerid))
{
new score = GetPlayerScore(playerid);
SetPlayerScore(playerid,score+1);
}
return 1;
}
when i now do /givescore i get +1 score, but can someone please tell me how to make it that i can givve it to others too, like /givescore [id]
Re: [unsolved] - very easy! (i think:P) -
CracK - 05.11.2009
I suggest you to use
zcmd and
sscanf
It will look like:
pawn Код:
cmd(givescore, playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new id;
if(sscanf(params,"i",id)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /givescore [id]");
else SetPlayerScore(id,GetPlayerScore(id)+1);
return 1;
}
return 0;
}
Re: [unsolved] - very easy! (i think:P) -
PANNA - 05.11.2009
Quote:
Originally Posted by CrαcK
I suggest you to use zcmd and sscanf
It will look like:
pawn Код:
cmd(givescore, playerid, params[]) { if(IsPlayerAdmin(playerid)) { new id; if(sscanf(params,"i",id)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /givescore [id]"); else SetPlayerScore(id,GetPlayerScore(id)+1); return 1; } return 0; }
|
can you please make it like above?
uf(strmp blah blah cuz im beginner in cripting and when i need to do all that things you suggest im getting crazy:P
Re: [unsolved] - very easy! (i think:P) -
CracK - 05.11.2009
Download and install zcmd include.
In script:
pawn Код:
#include <zcmd> //at the top
//copy and paste sscanf function and givescore command somewhere in your script (outside any callback!)
//for example
public OnPlayerCommandText(playerid, cmdtext[]) // < callback
{
//you probably have something here
return 0;
}
//paste sscanf and givescore command here
Re: [unsolved] - very easy! (i think:P) -
Peter_Corneile - 05.11.2009
Use dutils and ReturnUser function that is defined in dutils
Re: [unsolved] - very easy! (i think:P) -
Tony_Montana - 05.11.2009
you can use zcmd or strtok
zcmd take the Crack's code
if with strtok try this
pawn Код:
if(strcmp("/givescore",cmdtext,true,10) == 0)
{
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /givescore [id]");
return 1;
}
new pl = strval(tmp);
new score = GetPlayerScore(pl);
SetPlayerScore(pl,score+1);
return 1;
}
}
return 1;
}
Re: [unsolved] - very easy! (i think:P) -
saiberfun - 05.11.2009
https://sampwiki.blast.hk/wiki/Strtok
https://sampwiki.blast.hk/wiki/Zcmd
https://sampwiki.blast.hk/wiki/Sscanf
here sum more infos abou the suggested stuff :]