[HELP] Comparing names
#1

It's probably extremely simple, but I cannot see what I have done wrong.
pawn Код:
public OnPlayerSpawn(playerid)
{
    new name[MAX_PLAYER_NAME];
    name = GetPlayerName(playerid, name, sizeof(name));
    if(name == "dave")
    {
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,8,1);
        SetPlayerArmour(playerid,100);
    }
    else if(name == "bob")
    {
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,8,1);
        SetPlayerArmour(playerid,100);
    }
    else
    {
        GivePlayerWeapon(playerid,23,500);
    }
   
    return 1;
}
Код:
H:\sampserver0.3c\gamemodes\cjfreeroam.pwn(230) : error 033: array must be indexed (variable "name")
H:\sampserver0.3c\gamemodes\cjfreeroam.pwn(231) : error 033: array must be indexed (variable "name")
H:\sampserver0.3c\gamemodes\cjfreeroam.pwn(238) : error 033: array must be indexed (variable "name")
On lines;
pawn Код:
name = GetPlayerName(playerid, name, sizeof(name));
if(name == "dave")
else if(name == "bob")
Regards,
XxCozzaxX
Reply
#2

pawn Код:
public OnPlayerSpawn(playerid)
{
    new playername[64];
    GetPlayerName(playerid,playername,64);

    if(!strcmp(playername,"dave",true)) {
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,8,1);
        SetPlayerArmour(playerid,100);
    }
    else if(!strcmp(playername,"bob",true)) {
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,8,1);
        SetPlayerArmour(playerid,100);
    }
    else
    {
        GivePlayerWeapon(playerid,23,500);
    }
    return 1;
}
Reply
#3

tested ingame works fine
pawn Код:
new playername[MAX_PLAYER_NAME];
  GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
if(strcmp("bob", playername, false) == 0)
{
     GivePlayerWeapon(playerid,24,8000);        
     GivePlayerWeapon(playerid,24,8000);        
     GivePlayerWeapon(playerid,8,1);        
     SetPlayerArmour(playerid,100);
}
Reply
#4

Quote:
Originally Posted by Clive
Посмотреть сообщение
pawn Код:
public OnPlayerSpawn(playerid)
{
    new playername[64];
    GetPlayerName(playerid,playername,64);

    if(!strcmp(playername,"dave",true)) {
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,8,1);
        SetPlayerArmour(playerid,100);
    }
    else if(!strcmp(playername,"bob",true)) {
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,24,8000);
        GivePlayerWeapon(playerid,8,1);
        SetPlayerArmour(playerid,100);
    }
    else
    {
        GivePlayerWeapon(playerid,23,500);
    }
    return 1;
}
pawn Код:
new playername[24]; // not 64, it's like using whole moon for a bacteria's house...
Reply
#5

i got a smiliar problem ill need to check a name after a result from a database and need to compared with the current name but i dont now how to do it
pawn Код:
if(mysql_fetch_row(line)) //Fetches the line
            {
                   new data[2];//The data strings
                   new data2[4]; //The data variables
                   GetPlayerName(playerid,pname,24);
                   sscanf(line, "p|dds",data2[1], data2[2],data[1]); //Splits the line with sscanf
                   //vehicleowner = data[1];
                   mysql_real_escape_string(data[1],vehicleowner);
                   mysql_real_escape_string(pname,escpname);
                   //format(string,sizeof(string),"%s != %s",escpname,vehicleowner);
                   if(GetPlayerName(playerid,pname,24) != vehicleowner[24])
                   {
                   SendClientMessage(playerid,COLOR_YELLOW,"You have been removed from the vehicle. You are not the owner");
                   format(string, sizeof(string), "This vehicle is registered to Player: %s",vehicleowner);
                   SendClientMessage(playerid, COLOR_YELLOW, string);
                   RemovePlayerFromVehicle(playerid);
                   mysql_free_result();
            }]
As you may see i tried it with different ways but not luck
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)