SetPlayerScore help
#1

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);
Reply
#2

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.
Reply
#3

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

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

Use "strvalEx".
Reply
#5

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

Yeah so was your post - pretty genius-like
Reply
#7

Oh ye definately
Reply
#8

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)