enum / variable problem
#1

Hi... I'm making a vehicle system and I don't want to do it for each player again, therefore I used some enums...
like
Examplename[amountofvehicleslots]...

and now I got a little problem...
Код:
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));

if(listitem == 0){
 SetVehicleToRespawn(PrivateVehs[name][0]);
}
(that's at OnDialogResponse)...
it should respawn the first vehicle of the player that choose the function... but I get this error at the "SetVehicleToRespawn" line:
Код:
error 033: array must be indexed (variable "pname")
I guess because there is no "pname" defined in the PrivateVehs enum...
so how can I make it work?
Reply
#2

SetVehicleToRespawn(PrivateVehs[name][0]); -> SetVehicleToRespawn(vehicleid);

I think your trying to achieve something like this: SetVehicleToRespawn(GetPlayerVehicleID(playerid));
Reply
#3

Ehm kind off but not really...
I made this in a dialog which you can use anywhere... You get a list of your vehicles (atm I'm just working on the admin level which only has 1 vehicle so I can leave this step out and I guess I'll need to figure out that thingy here before I can do the vehicle choose:P) and some functions you can use. Like: Respawn, Repair, etc... so the problem is that I can't just get the ID of the vehicle the player is currently in, as it's a kind of a remote control.

Anymore ideas?
Reply
#4

Paste the "Remote control" script then.
Reply
#5

I already did so lol..
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
 if(dialogid == 1){
  if(response == 1){
   if(listitem == 0){
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    SetVehicleToRespawn(PrivateVehs[name][0]);
   } 
  }
 }
 return 1;
}
Reply
#6

Okay, what you want is an loop to get the vehicleid


pawn Код:
new vehicleid = -1;
for(new i; i < MAX_VEHICLES; i++)
{
     if(strmatch(Carstringtocheckhere,Carstringtomatchhere)) vehicleid = i; break;
}
now, SetVehicleToRespawn(vehicleid);
Reply
#7

and still...
how can I make it like "PrivateVehs[name][number]" with a variable for the name?...

I don't want to rewrite this for each admin...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)