SA-MP Forums Archive
enum / variable problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: enum / variable problem (/showthread.php?tid=184467)



enum / variable problem - Sascha - 20.10.2010

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?


Re: enum / variable problem - Cameltoe - 20.10.2010

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

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


Re: enum / variable problem - Sascha - 20.10.2010

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?


Re: enum / variable problem - Cameltoe - 20.10.2010

Paste the "Remote control" script then.


Re: enum / variable problem - Sascha - 20.10.2010

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;
}



Re: enum / variable problem - Cameltoe - 20.10.2010

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);



Re: enum / variable problem - Sascha - 20.10.2010

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...