SA-MP Forums Archive
SetPlayerScore help - 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: SetPlayerScore help (/showthread.php?tid=147696)



SetPlayerScore help - Memoryz - 13.05.2010

Okay so this is what I have:

Код:
CMD:setscore(playerid, params[]) {
 if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setscore [playerid] [score]");
 if(PlayerInfo[playerid][Admin] >= 4)
 {
  new tmp[256], idx;
  tmp = strtok(params,idx);
  if(!strlen(tmp))
  {
    SendClientMessage(playerid,0x0000FFFF,"Usage: /setscore [playerid] [score]");
    return 1;
  }
  new scoreid = strval(tmp);
  if(!IsPlayerConnected(scoreid))
  {
    SendClientMessage(playerid,COLOR_RED,"Invalid PlayerID");
    return 1;
  }
  tmp = strrest(params,idx);
  new pname[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[128];
  GetPlayerName(scoreid, pname, sizeof(pname));
  GetPlayerName(playerid, pname2, sizeof(pname2));
  tmp = strrest(params, idx);
  format(string, sizeof(string), "%s has set your score to %s", pname2, tmp);
  SendClientMessage(scoreid,COLOR_RED, string);
  SetPlayerScore(scoreid, 0);
  SetPlayerScore(scoreid, tmp); //Error on this line
  return 1;
 }
 else return SendClientMessage(playerid,COLOR_RED,"You aren't a level 4 admin.");
}
But when I compile this, I get
Quote:

error 035: argument type mismatch (argument 2)

On this line: SetPlayerScore(scoreid, tmp);


Re: SetPlayerScore help - juice.j - 13.05.2010

https://sampwiki.blast.hk/wiki/SetPlayerScore

SetPlayerScore expects an integer to be passed as a parameter. Without looking at your code one can already expect tmp to be a string.

Simply convert it to an integer when calling the function.

In general: Try to read from the errors, this case was more than obvious.


Re: SetPlayerScore help - Memoryz - 13.05.2010

Quote:
Originally Posted by juice.j
https://sampwiki.blast.hk/wiki/SetPlayerScore

SetPlayerScore expects an integer to be passed as a parameter. Without looking at your code one can already expect tmp to be a string.

Simply convert it to an integer when calling the function.

In general: Try to read from the errors, this case was more than obvious.
How can I convert it to an integer, when someone type in /setscore 0 50 they are integers.


Re: SetPlayerScore help - juice.j - 13.05.2010

As long as you get errors no one types anything as no amx file gets created .

Use "strvalEx".


Re: SetPlayerScore help - Antonio [G-RP] - 13.05.2010

Код:
SetPlayerScore(playerid, tmp);
Doesn't take a genius


Re: SetPlayerScore help - juice.j - 13.05.2010

Yeah so was your post - pretty genius-like


Re: SetPlayerScore help - Antonio [G-RP] - 13.05.2010

Oh ye definately


Re: SetPlayerScore help - Memoryz - 14.05.2010

Quote:
Originally Posted by Antonio (dominationrp.netii.net)
Код:
SetPlayerScore(playerid, tmp);
Doesn't take a genius
Idiot, read the script first, i dont wanna do it for the playerid, I wanna do it for the scoreid...

Doesn't take a genius


Re: SetPlayerScore help - Memoryz - 14.05.2010

Hmm, I still can't seem to get this working, anyone?


Re: SetPlayerScore help - dice7 - 14.05.2010

pawn Код:
SetPlayerScore(playerid, strval(tmp));