Vehicle angle.
#1

Hey guys.
Im using this filterscript, i put it in to my gamemode,
And its working exept for one thing.
The angle, vehicle angles arent saving as they should,
their, rotated by 25 degrees or something.

does anyone have any idea, on how to fix this?

https://sampforum.blast.hk/showthread.php?tid=584508
Reply
#2

Coordinated are fucked up. Use this
pawn Код:
CMD:vehicle(playerid,params[])
{
        new action,string[128];
        if(sscanf(params,"k<servervehiclemenu>S()[128]",action,string)) return SEM(playerid,"<USAGE>: /vehicle [create/delete/park/plate/color]");
        else
        {
            switch(action)
            {
                case 1:
                {
                    new model,color1,color2,vehplate[MAX_PLATE_NAME];
                    if(sscanf(string,"ddds["#MAX_PLATE_NAME"]",model,color1,color2,vehplate)) return SEM(playerid,"<USAGE>: /vehicle create [modelid] [color 1] [color 2] [plate name (max 30 chars)]");
                    if(model < 400 || model > 611) return SEM(playerid,"<ERROR>: You have entered an invalid modelid !");
                    if(Iter_Free(Vehicles) == -1) return SEM(playerid,"<ERROR>: No free vehicle slot available !");
                    if(color1 < 0 || color1 > 255 || color2 < 0 || color2 > 255) return SEM(playerid,"<ERROR>: You have entered an invalid colorid !");
                    new vehicleid = Iter_Free(Vehicles);
                    ServerVehicle[vehicleid][Model] = model;
                    ServerVehicle[vehicleid][ID] = vehicleid;
                    ServerVehicle[vehicleid][Color][0] = color1;
                    ServerVehicle[vehicleid][Color][1] = color2;
                    strmid(ServerVehicle[vehicleid][Plate],vehplate,0,strlen(vehplate),MAX_PLATE_NAME);
                    GetPlayerPos(playerid,ServerVehicle[vehicleid][Spawn][0],ServerVehicle[vehicleid][Spawn][1],ServerVehicle[vehicleid][Spawn][2]);
                    GetVehicleZAngle(vehicleid,ServerVehicle[vehicleid][Spawn][3]);
                    new ORM:ormid = ServerVehicle[vehicleid][ORM_ID] = orm_create("server_vehicles",Database);
                        orm_addvar_int(ormid,ServerVehicle[vehicleid][ID],"veh_id");
                        orm_addvar_string(ormid,ServerVehicle[vehicleid][Plate],MAX_PLATE_NAME,"veh_plate");
                        orm_addvar_int(ormid,ServerVehicle[vehicleid][Model],"veh_model");
                orm_addvar_int(ormid,ServerVehicle[vehicleid][Color][0],"veh_color_1");
                orm_addvar_int(ormid,ServerVehicle[vehicleid][Color][1],"veh_color_2");
                        orm_addvar_float(ormid,ServerVehicle[vehicleid][Spawn][0],"veh_x");
                        orm_addvar_float(ormid,ServerVehicle[vehicleid][Spawn][1],"veh_y");
                        orm_addvar_float(ormid,ServerVehicle[vehicleid][Spawn][2],"veh_z");
                        orm_addvar_float(ormid,ServerVehicle[vehicleid][Spawn][3],"veh_a");
                        orm_insert(ormid,"Vehicle_Create","dd",vehicleid,playerid);
                        orm_setkey(ormid,"veh_id");
                        }
                        case 2:
                        {
                            if(IsNull(string)) return SEM(playerid,"<USAGE>: /vehicle delete [vehicleid]");
                            new vehicleid = strval(string);
                        if(Iter_Contains(Vehicles,vehicleid))
                        {
                        format(string,sizeof(string),"<VEHICLEINFO>: {ffffff}(Server) Vehicle with {ffff00}id %d {ffffff}has been deleted!",vehicleid);
                        SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                        DestroyVehicle(VehicleID[vehicleid]);
                                        orm_delete(ServerVehicle[vehicleid][ORM_ID],true);
                                        Iter_Remove(Vehicles,vehicleid);
                        }
                        else SEM(playerid,"<ERROR>: Invalid vehicleid !");
                        }
                        case 3:
                        {
                            if(IsNull(string)) return SEM(playerid,"<USAGE>: /vehicle park [vehicleid]");
                            new vehicleid = strval(string);
                        if(Iter_Contains(Vehicles,vehicleid))
                        {
                            GetPlayerPos(playerid,ServerVehicle[vehicleid][Spawn][0],ServerVehicle[vehicleid][Spawn][1],ServerVehicle[vehicleid][Spawn][2]);
                        GetPlayerFacingAngle(playerid,ServerVehicle[vehicleid][Spawn][3]);
                        format(string,sizeof(string),"<VEHICLEINFO>: {ffffff}(Server) Vehicle with {ffff00}id %d {ffffff}has been parked!",vehicleid);
                    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                                        orm_update(ServerVehicle[vehicleid][ORM_ID]);
                }
                        else SEM(playerid,"<ERROR>: Invalid vehicleid !");
                        }
                        case 4:
                        {
                            new vehicleid,newplate[MAX_PLATE_NAME];
                            if(sscanf(string,"ds["#MAX_PLATE_NAME"]",vehicleid,newplate)) return SEM(playerid,"<USAGE>: /vehicle plate [modelid/vehicleid] [plate name (max 30 chars)]");
                                if(Iter_Contains(Vehicles,vehicleid))
                        {
                                        strmid(ServerVehicle[vehicleid][Plate],newplate,0,strlen(newplate),MAX_PLATE_NAME);
                                format(string,sizeof(string),"<VEHICLEINFO>: {ffffff}You have changed the vehicle name to '{ffff00}%s{ffffff}'",newplate);
                    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                                        orm_update(ServerVehicle[vehicleid][ORM_ID]);
                                }
                                else SEM(playerid,"<ERROR>: Invalid vehicleid !");
                        }
                        case 5:
                        {
                            new vehicleid,color1,color2;
                            if(sscanf(string,"ddd",vehicleid,color1,color2)) return SEM(playerid,"<USAGE>: /vehicle color [modelid/vehicleid] [color 1] [color 2]");
                                if(Iter_Contains(Vehicles,vehicleid))
                        {
                            ServerVehicle[vehicleid][Color][0] = color1;
                            ServerVehicle[vehicleid][Color][1] = color2;
                            format(string,sizeof(string),"<VEHICLEINFO>: {ffffff}You have changed the vehicle color with '{ffff00}id %d{ffffff}'",vehicleid);
                            SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                            orm_update(ServerVehicle[vehicleid][ORM_ID]);
                            }
                                else SEM(playerid,"<ERROR>: Invalid vehicleid !");
                        }
                        default: SEM(playerid,"<USAGE>: /vehicle [create/delete/park/plate/color]");
                }
        }
        return CMD_SUCCESS;
}

The problem was in
pawn Код:
GetPlayerFacingAngle(playerid,ServerVehicle[vehicleid][Spawn][3]);
Instead you should use
pawn Код:
GetVehicleZAngle(vehicleid,ServerVehicle[vehicleid][Spawn][3]);
Reply
#3

I advice you to read the Wiki carefully, as that is the source for each and every function that follows sa-mp.
Each function has their Warnings and Notes that are worth reading.
https://sampwiki.blast.hk/wiki/GetPlayerFacingAngle
is saying:


So what he said above is correct

Use the wiki next time
Reply
#4

Well im sorry, but i am actually using GetVehicleZangle
Reply
#5

The content of the link you've sent uses GetPlayerFacingAngle. I have checked the code, and it should be what it is.

However:
Quote:

The angle, vehicle angles arent saving as they should,
their, rotated by 25 degrees or something.

This tells me nothing. Provide more information and I'll assist you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)