Command with ID problem -
nejc001 - 19.03.2011
I Actualy understand the problem, but have no idea how to fix it :/
error 006: must be assigned to an array
pawn Код:
//On top
new level[MAX_PLAYERS];
//UNDER OnPlayerCommandText
if (strcmp(cmd, "/setlevel", true) == 0)
{
new tmp[20], id;
tmp = strtok(cmdtext, idx);
if(account[playerid] == ADMIN || account[playerid] == OWNER)
{
if (IsPlayerConnected(id))
{
if (strlen(tmp))
{
id = strval(tmp);
new promname[MAX_PLAYERS],levelid[28];
levelid = strtok(cmdtext,idx);
GetPlayerName(id,promname,sizeof (promname));
format(promname, sizeof promname, "%s has been promoted by admin to level %d",promname,levelid);
SendClientMessageToAll(0xFF0000AA, promname);
SendClientMessage(id, 0xFF0000AA, "You have been promoted.");
level[id] = levelid; //error 006: must be assigned to an array
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setlevel [levelid]");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Invalid Player ID");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "You are not admin");
}
return 1;
}
Re: command problem -
Biesmen - 19.03.2011
Change
Into
pawn Код:
new promname[MAX_PLAYER_NAME]
And change
pawn Код:
GetPlayerName(id,promname,sizeof promname);
Into
pawn Код:
GetPlayerName(id,promname,sizeof(promname));
Re: command problem -
nejc001 - 19.03.2011
ok fixed that, but this still doesnt help me with my problem..
wut bout this?
pawn Код:
format(promname, sizeof promname, "%s has been promoted by admin to level %d",promname,levelid);
into this?
pawn Код:
format(promname, sizeof (promname), "%s has been promoted by admin to level %d",promname,levelid);
Re: command problem -
Biesmen - 19.03.2011
Didn't read that. But yeah, change that too.
Edit: I saw the error is here:
level[id] = levelid;.
Where did you define level?
If you defined it at the top of the script, where it should be definned, change that to:
Re: command problem -
nejc001 - 19.03.2011
i have from beggining on top
Look my first pawn message, its already defined there..
Re: command problem -
nejc001 - 21.03.2011
I tryed with something else, but its same problem as here..
Somebody could help?
You can bumb topics every 24h right? I couldnt find the forum rules -.-
Re: command problem -
nejc001 - 24.03.2011
bump :/
Re: command problem -
THE_KNOWN - 24.03.2011
change = > new promname[MAX_PLAYERS],levelid[28];
into
new proname[MAX_PLAYERS],levelid;
Re: command problem -
nejc001 - 24.03.2011
EDIT:
actualy, now i have error in line: levelid = strtok(cmdtext,idx);
error: must be assigned to an array
Re: command problem -
PinkFloydLover - 24.03.2011
Try change the levelid = strtok...
into levelid = strval(tmp);
since its an integar
Re: command problem -
THE_KNOWN - 24.03.2011
well idk how to use the old strtok. but if you dont have many cmds i suggest you switch to zmd and sscanf. its much more easier. I bet youll get more help with zcmd commands than strtok
P.S-Others please dont get angry and tell me to stfu if i cant help -.-
Re: command problem -
THE_KNOWN - 24.03.2011
idk if this will work as i said im a noob in strtok but...
try this
level[id] = levelid;
Re: command problem -
nejc001 - 24.03.2011
Quote:
Originally Posted by Cale
Try change the levelid = strtok...
into levelid = strval(tmp);
since its an integar
|
Yes, this what i was looking for..im still new with this strval, strtok things.. thanks
Re: command problem -
THE_KNOWN - 24.03.2011
ifyour new you better switch then
![Wink](images/smilies/wink.png)
trust me its much more comfortable and shorter todo than this
Re: command problem -
nejc001 - 24.03.2011
i knew that with level[id] already
![Wink](images/smilies/wink.png)
thanks anyway..
well not actualy new, im scripting my own server..just i never actuly understand this strtok, strval, zcmd... things..i just copied this, cuz i didn't actualy care whats that.. i just needed a cmd xD
ahh, yea, need to learn that or i never will be a good scriper..