Quote:
|
Originally Posted by SaiBerFun
or just use mine which is better than this actually because it checks more stuff n gives infos about what just happened
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate) { if(IsPlayerInVehicle(playerid, 462)) { if(newstate == 2)//checks if player entered as driver { if(GetPlayerMoney(playerid) >= 25) //25 = the money u want the car to cost. { GivePlayerMoney(playerid,-25); SendClientMessage(playerid,YOUR_COLOR,"You just bought this car."); } else SendClientMessage(playerid,YOUR_COLOR,"You don't have enought money for this car."); RemovePlayerFromVehicle(playerid); } else SendClientMessage(playerid,YOUR_COLOR,"You need to enter as driver to buy this car."); //change YOUR_COLOR to the colors you have got and that you want to use RemovePlayerFromVehicle(playerid); } }
|
Yes it gives information, but it wasn't asked, and I don't see any check that i haven't done.
Btw, you should check if newstate = 2 before checking if the vehicle ID is 462. OnPlayerStateChange is also called when you exit a vehicle or spawn for example.
Also use braces for your esle statments.