error 033: array must be indexed (variable "id")
#1

im getting these errors :

Код:
C:\Documents and Settings\Owner\Desktop\test\gamemodes\DDPTDM.pwn(746) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\Owner\Desktop\test\gamemodes\DDPTDM.pwn(748) : error 033: array must be indexed (variable "id")
C:\Documents and Settings\Owner\Desktop\test\gamemodes\DDPTDM.pwn(750) : error 033: array must be indexed (variable "id")
C:\Documents and Settings\Owner\Desktop\test\gamemodes\DDPTDM.pwn(756) : error 033: array must be indexed (variable "id")
C:\Documents and Settings\Owner\Desktop\test\gamemodes\DDPTDM.pwn(762) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
with this code.

pawn Код:
CMD:setlevel(playerid,params[])
{
    if(SInfo[playerid][pAdmin] < 4&& !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_ERROR,"You don't have the permission to use this command!");
    new id[32],level,string1[256],string2[256],string3[256],string4[256];if(sscanf(params,"ud",id,level)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /setlevel [playerid] [level 0/3]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_ERROR,"Player not connected."); //Error line 746
    if(level > 5) return SendClientMessage(playerid,COLOR_ERROR,"Error! You can only pick between level 0/5 (0: Player - 1: Mini Moderator - 2: Moderator - 3: Mini Administrator - 4: Administrator - 5: Server Owner)");
    if(SInfo[id][pAdmin] < level)// Error line 748
    {
        SInfo[id][pAdmin] = level;// Error line 750
        format(string1,sizeof string1, "You have promoted %s succesfully to level %i.",id,level);
        SendClientMessage(playerid, COLOR_GREEN, string1);
        format(string2,sizeof string2, "Congratulations! You have been promoted to level %i.",level);
        SendClientMessage(playerid, COLOR_GREEN, string2);
    } else {
        SInfo[id][pAdmin] = level;// error line 756
        format(string3,sizeof string3,"You have demoted %s succesfully to level %i.",id, level);
        SendClientMessage(playerid, COLOR_GREEN, string3);
        format(string4,sizeof string4,"You have been demoted to level %i.",level);
        SendClientMessage(playerid, COLOR_GREEN, string4);
    }
    SaveUser(id);//Error line 762
    return 1;
}
Reply
#2

Change
pawn Код:
new id[32]

//to
new id,
Reply
#3

I did that before but it wont display the players name.
it will say,

Код:
You have promoted  succesfully to level 5.
when it should say

Код:
You have promoted [DDP]xXitsgodzillaXx succesfully to level 5.
Reply
#4

Use GetPlayerName(id)
Reply
#5

some more specifics would be nice.
Reply
#6

This is what I use,
pawn Код:
//Somewhere in the top of your script
stock RPN(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}

//Your CMD
CMD:setlevel(playerid,params[])
{
    if(SInfo[playerid][pAdmin] < 4&& !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_ERROR,"You don't have the permission to use this command!");
    new id,level,string1[256],string2[256],string3[256],string4[256];if(sscanf(params,"ud",id,level)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /setlevel [playerid] [level 0/3]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_ERROR,"Player not connected."); //Error line 746
    if(level > 5) return SendClientMessage(playerid,COLOR_ERROR,"Error! You can only pick between level 0/5 (0: Player - 1: Mini Moderator - 2: Moderator - 3: Mini Administrator - 4: Administrator - 5: Server Owner)");
    if(SInfo[id][pAdmin] < level)// Error line 748
    {
        SInfo[id][pAdmin] = level;// Error line 750
        format(string1,sizeof string1, "You have promoted %s succesfully to level %i.",RPN(id),level);
        SendClientMessage(playerid, COLOR_GREEN, string1);
        format(string2,sizeof string2, "Congratulations! You have been promoted to level %i.",level);
        SendClientMessage(playerid, COLOR_GREEN, string2);
    } else {
        SInfo[id][pAdmin] = level;// error line 756
        format(string3,sizeof string3,"You have demoted %s succesfully to level %i.",RPN(id), level);
        SendClientMessage(playerid, COLOR_GREEN, string3);
        format(string4,sizeof string4,"You have been demoted to level %i.",level);
        SendClientMessage(playerid, COLOR_GREEN, string4);
    }
    SaveUser(id);
    return 1;
}
Reply
#7

pawn Код:
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
This is what u must use there. Just put "GetName(id)" there.
Reply
#8

Oh so I just needed to add a stock function. Well thanks! +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)