Problem with dcmd & sscanf - 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: Problem with dcmd & sscanf (
/showthread.php?tid=71327)
Problem with dcmd & sscanf -
Oxside - 31.03.2009
Hello
I got the next thing:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(givelevel, 8, cmdtext);
return 0;
}
dcmd_givelevel(playerid, params[])
{
new
id,
reason[64];
if (sscanf(params, "uz", id, reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/givelevel <playerid/partname> <level>\"");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
else
{
Level[id] = reason;
format(reason, sizeof (reason), "You has got an level up!", reason[0] ? (" for: ") : (""), reason);
SendClientMessage(id, 0xFF0000AA, reason);
SendClientMessage(playerid, 0x00FF00AA, "Level has been given!");
}
return 1;
}
And i get this error:
error 006: must be assigned to an array
Its on line 131 for me
The next:
This was like this:
Код:
Level[playerid] = 1;
Playerid i changed to id give someone else an level
But now i want to change the 1 to an variable so you can fill in wich level somei going to be!
BTW: I got the define of dcmd andhe code of sscanf !
PLease help i need this!
Oxside
P.S I use reason because this was orginal the /ban command from the samp wiki!
Re: Problem with dcmd & sscanf -
ICECOLDKILLAK8 - 31.03.2009
Use this code instead
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(givelevel, 9, cmdtext);
return 0;
}
dcmd_givelevel(playerid, params[])
{
new id, level;
if (sscanf(params, "ii", id, level)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/givelevel <playerid/partname> <level>\"");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
Level[id] = level;
SendClientMessage(id, 0xFF0000AA, "You got a level up");
SendClientMessage(playerid, 0x00FF00AA, "Level has been given!");
}
return 1;
}
Re: Problem with dcmd & sscanf -
Oxside - 31.03.2009
Thanks mate

There where some errors with some braces but i fixed
Fixed code
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(givelevel, 8, cmdtext);
return 0;
}
dcmd_givelevel(playerid, params[])
{
new id, level;
if (sscanf(params, "ii", id, level)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/givelevel <playerid/partname> <level>\"");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
Level[id] = level;
SendClientMessage(id, 0xFF0000AA, "You got a level up");
SendClientMessage(playerid, 0x00FF00AA, "Level has been given!");
return 1;
}