SA-MP Forums Archive
Problem with the ZAngle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with the ZAngle (/showthread.php?tid=629857)



Problem with the ZAngle - Mencent - 04.03.2017

Hello!

I have a little problem. I did a little command to create some vehicles. When I want to park these with an extra command so the vehicle destroys and creates again to save the positions (so that when the vehicle destroys that it will spawn at the latest position).
But: The ZAngle doesn't update and this vehicle will stand always in the equal direction.

PHP код:
ocmd:apark(playerid,params[])
{
    if(
Player[playerid][pAdmin] < 5)return SendClientMessage(playerid,-1,"{b65e5e}Fehler:{FFFFFF} Du besitzt nicht die Rechte fьr diesen Befehl!");
    if(!
IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,-1,"{b65e5e}Fehler:{FFFFFF} Du bist in keinem Fahrzeug!");
    new 
Float:X,Float:Y,Float:Z,Float:A,string[20],query[200];
    
GetPlayerPos(playerid,X,Y,Z);
    
GetPlayerFacingAngle(playerid,A);
    for(new 
i,j=MAX_POLICE_CARS;i<j;i++)
    {
        if(
PoliceCars[i][polVehID] == GetPlayerVehicleID(playerid))
        {
            
mysql_format(handle,query,sizeof(query),"UPDATE `policecars` SET `parkx`='%f',`parky`='%f',`parkz`='%f',`parka`='%f' WHERE `db_id`='%d'",X,Y,Z,A,PoliceCars[i][polDB_ID]);
            
mysql_tquery(handle,query,"","");
            
SetVehicleZAngle(PoliceCars[i][polVehID],A);
            
DestroyVehicle(PoliceCars[i][polVehID]);
            
PoliceCars[i][polVehID] = CreateVehicle(PoliceCars[i][polModel],X,Y,Z,A,PoliceCars[i][polFarbe1],PoliceCars[i][polFarbe2],-1,0);
            
format(string,sizeof(string),"PD%04d",PoliceCars[i][polVehID]);
            
SetVehicleNumberPlate(PoliceCars[i][polVehID],string);
            
SendClientMessage(playerid,-1,"{30983c}** Du hast das Polizeifahrzeug erfolgreich umgeparkt!");
            
PutPlayerInVehicle(playerid,PoliceCars[i][polVehID],0);
            return 
1;
        }
    }
    return 
1;

That's the park command.

I know that's a samp bug, but how can I fix this?

Best wishes.


Re: Problem with the ZAngle - GoldenLion - 04.03.2017

https://sampwiki.blast.hk/wiki/GetVehicleZAngle instead of GetPlayerFacingAngle.


Re: Problem with the ZAngle - Mencent - 04.03.2017

Thanks!!!

I thought it isn't important which of these functions (GetPlayerPos and GetPlayerFacingAngle or GetVehiclePos and GetVehicleZAngle) I use.

But, it solved my problem. THAAANKS