Array must be indexed
#1

fixed
Reply
#2

Quote:
Originally Posted by Ken97
Посмотреть сообщение
I want to check if the ownersname currently connected is = to the vehicle data's owner
the problem is it's sending an error:
1. Array must be indexed(Variablewnername)
2. Empty Statement




Being a noob an' all, I do not know how to compare two strings if they're the same,
I could use strcmp but I'm still stucked like one happened up top.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new ownername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, ownername, sizeof(ownername));
    if(strcmp(ownername, AVehicleData[vehicleid][Owner], true) == 0)
    {
        new string[128];
        format(string,sizeof(string), "You are the owner of this vehicle");
        SendClientMessage(playerid, 0x0FF0000AA, string);
    }
return 1;
}
Reply
#3

As far as I'm aware you can't check strings like that, use strcmp instead.
Reply
#4

Quote:
Originally Posted by Adytza.
Посмотреть сообщение
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new ownername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, ownername, sizeof(ownername));
    if(AVehicleData[vehicleid][Owner] == ownername); // error line
    {
        new string[128];
        format(string,sizeof(string), "You are the owner of this vehicle");
        SendClientMessage(playerid, 0x0FF0000AA, string);
    }
return 1;
}
Still the same error :/



Quote:
Originally Posted by oliverrud
Посмотреть сообщение
As far as I'm aware you can't check strings like that, use strcmp instead.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new ownername[50];
    new player1;
    new owner = AVehicleData[vehicleid][Owner];
    GetPlayerName(player1, ownername, sizeof(ownername));
    if(!strcmp(owner, "", true)) // I can't put ownername on the ""
    {
        new string[128];
        format(string,sizeof(string), "You are not the owner of this vehicle");
        SendClientMessage(playerid, 0x0FF0000AA, string);
    }
return 1;
}
this code, does not give errors, but i'm just stuck on what to put between ""
Reply
#5

Quote:
Originally Posted by Ken97
Посмотреть сообщение
Still the same error :/





pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new ownername[50];
    new player1;
    new owner = AVehicleData[vehicleid][Owner];
    GetPlayerName(player1, ownername, sizeof(ownername));
    if(!strcmp(owner, "", true)) // I can't put ownername on the ""
    {
        new string[128];
        format(string,sizeof(string), "You are not the owner of this vehicle");
        SendClientMessage(playerid, 0x0FF0000AA, string);
    }
return 1;
}
this code, does not give errors, but i'm just stuck on what to put between ""
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new ownername[MAX_PLAYER_NAME];
    new owner = AVehicleData[vehicleid][Owner];
    GetPlayerName(playerid, ownername, sizeof(ownername));
    if(!strcmp(owner, owername, true)) // I can't put ownername on the ""
    {
        new string[128];
        format(string,sizeof(string), "You are the owner of this vehicle");
        SendClientMessage(playerid, 0x0FF0000AA, string);
    }
return 1;
}
Reply
#6

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new ownername[50];
    new player1;
      new owner;
    owner = AVehicleData[vehicleid][Owner];// symbol is assigned a value that is never used: owner
    GetPlayerName(player1, ownername, sizeof(ownername));
    if(!strcmp(owner,ownername , false))//argument type mismatch(argument 1)
    {
        new string[128];
        format(string,sizeof(string), "You are not the owner of this vehicle");
        SendClientMessage(playerid, 0x0FF0000AA, string);
    }
return 1;
}
See errors above
Reply
#7

Quote:
Originally Posted by Ken97
Посмотреть сообщение
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new ownername[50];
    new player1;
      new owner;
    owner = AVehicleData[vehicleid][Owner];// symbol is assigned a value that is never used: owner
    GetPlayerName(player1, ownername, sizeof(ownername));
    if(!strcmp(owner,ownername , false))//argument type mismatch(argument 1)
    {
        new string[128];
        format(string,sizeof(string), "You are not the owner of this vehicle");
        SendClientMessage(playerid, 0x0FF0000AA, string);
    }
return 1;
}
See errors above
First of all.. why do you keep changing what i've made ? you keep chaging playerid to player1 ? what for ? and [MAX_PLAYER_NAME] to [50] ?
This V compiles fine for me..
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new ownername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, ownername, sizeof(ownername));
    if(!strcmp(ownername,AVehicleData[vehicleid][Owner],false))
    {
        new string[128];
        format(string,sizeof(string), "You are not the owner of this vehicle");
        SendClientMessage(playerid, 0x0FF0000AA, string);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)