180° vehicle rotation on key press
#8

Quote:
Originally Posted by VinnyOne
Посмотреть сообщение
this is what i tried but it didnt work i guess it was just a bad script

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_SUBMISSION)
       {
       new vehicleid = GetPlayerVehicleID(playerid);
       if(IsPlayerInVehicle(playerid, vehicleid))
       {
      		new currentveh;
    		new Float:angle;
    		currentveh = GetPlayerVehicleID(playerid);
    		GetVehicleZAngle(currentveh, angle);
    		SetVehicleZAngle(currentveh, angle+180);
    		}
}
The code is not that bad but it surely contains unnecessary variable declarations such as 'vehicleid' and 'currentveh'.
SA:MP has a function called 'IsPlayerInAnyVehicle' so there is no need to get the Player' vehicle ID and then use a function to use it.
You are already getting the player's vehicle id in the 'vehicleid' variable, there is absolutely no need to declare a second variable in the exact same function with the exact same use. The rest seems good.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SUBMISSION)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            new Float:angle;
            // OR:
            // new vehicleid = GetPlayerVehicleID(playerid), Float:angle;
            GetVehicleZAngle(vehicleid, angle);
            SetVehicleZAngle(vehicleid, angle+180.0);
        }
    }
    return 1;
}
Reply


Messages In This Thread
180° vehicle rotation on key press - by VinnyOne - 21.02.2015, 17:40
Re: 180° vehicle rotation on key press - by Pottus - 21.02.2015, 17:43
Re: 180° vehicle rotation on key press - by Puppy - 21.02.2015, 17:44
Re : Re: 180° vehicle rotation on key press - by VinnyOne - 21.02.2015, 17:45
Re: 180° vehicle rotation on key press - by Pottus - 21.02.2015, 17:47
Re : Re: 180° vehicle rotation on key press - by VinnyOne - 21.02.2015, 17:48
Re : Re: 180° vehicle rotation on key press - by VinnyOne - 21.02.2015, 17:50
Re: Re : Re: 180° vehicle rotation on key press - by AndySedeyn - 21.02.2015, 19:13
Re: 180° vehicle rotation on key press - by Patrik356b - 22.02.2015, 09:49

Forum Jump:


Users browsing this thread: 4 Guest(s)