[unsolved] - very easy! (i think:P)
#1

Код:
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]
Reply
#2

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;
}
Reply
#3

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
Reply
#4

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
Reply
#5

Use dutils and ReturnUser function that is defined in dutils
Reply
#6

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;
}
Reply
#7

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 :]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)