#1

i want to make aka command i started making it when i got to this point i compiled i had 1 error and i don't know how to fix it

pawn Код:
dcmd_aka(playerid, params[])
{
    new cmdreason[24];
    new pname[24];
    if(sscanf(params,"s[24]",cmdreason))
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] {FFFFFF}USAGE /aka (Account)");
        return 1;
    }
    if(!udb_Exists(cmdreason))
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] {FFFFFF}This account didn't found try another one");
        return 1;
    }
    for(new i=0; i<MAX_PLAYERS_; i++)
    {
        GetPlayerName(i,pname,sizeof(pname));
        if(pname == cmdreason) // 8008
        {
            SendClientMessage(playerid,COLOR_RED,"[ERROR] {FFFFFF}You can't remove this account because the account owner is in-game");
            return 1;
        }
    }
   
    /*GetPlayerName*/
}
Код:
C:\Users\maher\Desktop\ahmad ghanayem\ълрйеъ\Iron-Players\gamemodes\Iron-Players.pwn(8008) : error 033: array must be indexed (variable "pname")
Reply
#2

You need to use GetPlayerName, example from samp wiki:
pawn Код:
new pname[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
 
format(string, sizeof(string), "%s has joined the server.", name);
SendClientMessageToAll(0xC4C4C4FF, string);
I advice you to make a stock of it like this (you can just use this one, its also from the samp wiki)
pawn Код:
stock PlayerName(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    return pname;
}
If you use this stock you can remove the getplayername and the pname variable and relace it with PlayerName in your command

Hope that helped! Good luck.
Reply
#3

pawn Код:
dcmd_aka(playerid, params[])
{
    new cmdreason[24];
    new pname[MAX_PLAYER_NAME];
    if(sscanf(params,"s[24]",cmdreason))
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] {FFFFFF}USAGE /aka (Account)");
        return 1;
    }
    if(!udb_Exists(cmdreason))
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] {FFFFFF}This account didn't found try another one");
        return 1;
    }
    for(new i=0; i<MAX_PLAYERS_; i++)
    {
        GetPlayerName(i,pname,sizeof(pname));
        if(pname == cmdreason) // 8008
        {
            SendClientMessage(playerid,COLOR_RED,"[ERROR] {FFFFFF}You can't remove this account because the account owner is in-game");
            return 1;
        }
    }
   
    /*GetPlayerName*/
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)