command problem
#1

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

Change
pawn Код:
new promname[128]
Into
pawn Код:
new promname[MAX_PLAYER_NAME]
And change
pawn Код:
GetPlayerName(id,promname,sizeof promname);
Into
pawn Код:
GetPlayerName(id,promname,sizeof(promname));
Reply
#3

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

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:
pawn Код:
new level[MAX_PLAYERS];
Reply
#5

i have from beggining on top
pawn Код:
new level[MAX_PLAYERS];
Look my first pawn message, its already defined there..
Reply
#6

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

bump :/
Reply
#8

change = > new promname[MAX_PLAYERS],levelid[28];

into

new proname[MAX_PLAYERS],levelid;
Reply
#9

EDIT:
actualy, now i have error in line: levelid = strtok(cmdtext,idx);
error: must be assigned to an array
Reply
#10

Try change the levelid = strtok...
into levelid = strval(tmp);

since its an integar
Reply
#11

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

idk if this will work as i said im a noob in strtok but...

try this

level[id] = levelid;
Reply
#13

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

ifyour new you better switch then trust me its much more comfortable and shorter todo than this
Reply
#15

i knew that with level[id] already 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..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)