25.11.2014, 13:07
Can anyone give me an idea on how to make a pickup, that when picked up it spawns a vehicle that nobody but you can enter it. What I tried doing is creating a variable, let's just say pizzaboy[MAX_PLAYERS];
When you enter a pickup, it spawns the car and everything is ok, but there is one problem though. I've made more cars: sweeper[MAX_PLAYERS], tractor[MAX_PLAYERS]. And now when I enter one of them, sometimes they get the wrong callback (I enter the sweeper and it acts as if its the pizzaboy). Does anyone know what am I doing wrong? Maybe you have a better idea.
Here's some code:
Pizzaboy pickup code:
now here's the OnPlayerStateChange callback
When you enter a pickup, it spawns the car and everything is ok, but there is one problem though. I've made more cars: sweeper[MAX_PLAYERS], tractor[MAX_PLAYERS]. And now when I enter one of them, sometimes they get the wrong callback (I enter the sweeper and it acts as if its the pizzaboy). Does anyone know what am I doing wrong? Maybe you have a better idea.
Here's some code:
Pizzaboy pickup code:
Код:
if(pickupid == ppizzaboy) { if(pInfo[playerid][Darbas] == DARBAS_PICININKAS || pInfo[playerid][Admin] >= 2) { if(IsValidVehicle(pizzaboy[playerid])){ DestroyVehicle(sweeper[playerid]); } pizzaboy[playerid] = CreateVehicle(448,218.9097,-180.5808,1.1772,85.6636,3,6,-1); PutPlayerInVehicle(playerid,pizzaboy[playerid],0); } else { //bla bla bla not a pizzaguy } }
Код:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) { if(GetPlayerVehicleID(playerid) == sweeper[playerid]) { if(pInfo[playerid][Darbas] == DARBAS_SLAVEJAS || pInfo[playerid][Admin] >= 2) { //bla bla sweeper } else { KickPlayerOutOfVehicle(playerid); //bla bla wrong job mate } } else if(GetPlayerVehicleID(playerid) == pizzaboy[playerid]) //pizzaboy { if(pInfo[playerid][Darbas] == DARBAS_PICININKAS || pInfo[playerid][Admin] >= 2) { //Bla bla pizzaguy stuff } else { KickPlayerOutOfVehicle(playerid); //Bla bla not your car } }