PDA

View Full Version : Little Help


Sanady
13/07/2015, 09:37 PM
Hello everybody, I have little problem, I created command which is giving player vehicle and also putting player automaticly into vehicle, but when other player kill that player who is in car created by admin, car stays on same position, but in script is defined that if someone kill player who is in vehicle which admin gave to automaticly that vehicle will be destroyed, but it`s buggy, please check it.


public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerInVehicle(playerid, AdminCar)) return DestroyVehicle(AdminCar);
return 1;
}

Toxik
13/07/2015, 10:34 PM
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerInVehicle(playerid, AdminCar));
DestroyVehicle(AdminCar);
return 1;
}

Virtual1ty
13/07/2015, 11:45 PM
Please stop naming all of your topics "Little help", little help on what? Describe what is the problem/what you're having trouble with so others would instantly know when they look on the thread topic. Also keep it concise. I am sorry but that are just some general forum guidelines this board should enforce and I guess there just aren't enough moderators to keep an eye for this.

On topic: if the player is dead, he can't be in a vehicle, can he now? That check is useless and it's why your code is failing.
Also I don't understand what do you want, for the vehicle not to be destroyed or? You should show us more code than just one line of code where you "destroy" the vehicle.

Sanady
14/07/2015, 12:22 PM
Please stop naming all of your topics "Little help", little help on what? Describe what is the problem/what you're having trouble with so others would instantly know when they look on the thread topic. Also keep it concise. I am sorry but that are just some general forum guidelines this board should enforce and I guess there just aren't enough moderators to keep an eye for this.

On topic: if the player is dead, he can't be in a vehicle, can he now? That check is useless and it's why your code is failing.
Also I don't understand what do you want, for the vehicle not to be destroyed or? You should show us more code than just one line of code where you "destroy" the vehicle.

Thank you for your nicely help, but next time you don`t comment my title of topic, thank you :)

FSAOskar
14/07/2015, 12:26 PM
You could do it like that:

Create 2 variables. Use the first one save if the player is in a vehicle or not and the second one to save his vehicle id.
Then under OnPlayerStateChange update both variables depending on his new state.
When the player dies --> Check if he was in a vehicle ---> Destroy the vehicle

Virtual1ty
14/07/2015, 02:25 PM
Thank you for your nicely help, but next time you don`t comment my title of topic, thank you :)
You still haven't told us what it is that you want. For the vehicle to be destroyed or not?
If you do want the vehicle to be destroyed then save the vehicle id of the vehicle the player was previously inside, under OnPlayerStateChange check if he changed states from state driver to state wasted, check if his last vehicle was "AdminCar" (by checking if that variable you just made equals the AdminCar variable), do an inverse check of what you did under OnPlayerDeath, check if the player is not in a vehicle and destroy it, like so: "if (!IsPlayerInVehicle(playerid, AdminCar)) DestroyVehicle(AdminCar);", actually you don't need that last "IsPlayerInVehicle" check but just to play it safe...

KillerDVX
15/07/2015, 04:52 AM
You still haven't told us what it is that you want.

Next time, read the topics carefully.

in script is defined that if someone kill player who is in vehicle which admin gave to automaticly that vehicle will be destroyed, but it`s buggy

So, would you try this :

public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerInVehicle(playerid,AdminCar))
{
DestroyVehicle(AdminCar);
return 1;
}
return 1;
}