Quote:
Originally Posted by introzen
What you're dealing with here is a native callback versus a function. In this case, when the player state changes. The function must be called by you in the script. Do realize that callbacks are regular functions aswell, but set to be called on some events by the SA-MP developer team.
And example of this would be the following.
PHP Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
TaxiOrDestroy(playerid); //Call your function
}
return 1;
}
PHP Code:
TaxiOrDestroy(playerid) {
new vehicleid = GetPlayerVehicleID(playerid);
new vehicle = GetVehicleModel(vehicleid);
if(vehicle == 420) return SendClientMessage(playerid, -1, "Welcome to the taxi.");;
DestroyVehicle(vehicleid);
SendClientMessage(playerid, -1, "This is not a taxi. Destroying the vehicle.");
return 1;
}
Also, never use public on your own functions unless they need to be called at run time.
|
it is okay, i figured it out. Thanks for the explanation and examples.
i am grateful to everyone who helped ! Have a nice day..