Wrong Angle
#1

Alright so the problem is simple, if you /park a vehicle, it will respawn at wrong Angle angle for some reason

PHP код:
CMD:park(playerid,params[]) {
    
#pragma unused params
    
new vid GetPlayerVehicleID(playerid), Float:tmpPos[4], vwInt;
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside any vehicle");
    if(
VehInfo[vid][VehMasterID] == AccInfo[playerid][ID] || VehInfo[vid][VehFaction] == AccInfo[playerid][PlayerFaction] && AccInfo[playerid][PlayerLeader]) {
        
GetVehiclePos(vid,tmpPos[0],tmpPos[1],tmpPos[2]);
        
GetVehicleZAngle(vid,tmpPos[3]);
        
vw GetVehicleVirtualWorld(vid);
        
Int GetPlayerInterior(playerid);
        
SendClientMessage(playerid,COLOR_GREEN,"You have parked your vehicle");
        
VehInfo[vid][VehPosX] = tmpPos[0];
        
VehInfo[vid][VehPosY] = tmpPos[1];
        
VehInfo[vid][VehPosZ] = tmpPos[2];
        
VehInfo[vid][VehPosA] = tmpPos[3];
        
VehInfo[vid][VehInterior] = Int;
        
VehInfo[vid][VehWorld] = vw;
        new 
query[128];
        
mysql_format(mysqlquerysizeof(query), "UPDATE `vehicles` SET `PosX`=%f,`PosY`=%f,`PosZ`=%f,`PosA`=%f WHERE ID=%d",tmpPos[0],tmpPos[1],tmpPos[2],tmpPos[3],VehInfo[vid][VID]);
        
mysql_tquery(mysqlquery);
    }
    return 
true;
}
public 
OnVehicleSpawn(vehicleid)
{
    
SetVehiclePos(vehicleid,VehInfo[vehicleid][VehPosX],VehInfo[vehicleid][VehPosY],VehInfo[vehicleid][VehPosZ]);
    
SetVehicleZAngle(vehicleid,VehInfo[vehicleid][VehPosA]);
    
SetVehicleVirtualWorld(vehicleid,VehInfo[vehicleid][VehWorld]);
    
LinkVehicleToInterior(vehicleid,VehInfo[vehicleid][VehInterior]);
    return 
1;

And yes the angle is a float
PHP код:
Float:VehPosA
print
PHP код:
printf("Server ID: %i || SQL ID: %i",vid,VehInfo[vid][VID]);
printf("%.2f",tmpPos[3]);
printf("%.2f",VehInfo[vid][VehPosA]);
[
02:27:52Server ID40 || SQL ID65
[02:27:52326.46
[02:27:52326.46 

The problem happens after I use SetVehicleToRespawn on it
Reply
#2

https://sampwiki.blast.hk/wiki/GetVehicleZAngle
Reply
#3

Quote:
Originally Posted by Kevln
Посмотреть сообщение
Thank you for linking me to something I have.
pawn Код:
GetVehicleZAngle(vid,tmpPos[3]);
Please read the topic before you post.
Reply
#4

what angle does it set it at? random or 0 ?
does it happen to all vehicles ? idk.. maybe someone else will reply with solution
Reply
#5

Where exactly are you respawning it?
Reply
#6

pawn Код:
// ** INCLUDES

#include <a_samp>
#include <zcmd>

// ** ARRAYS AND ENUMERATORS

enum eVehicleInfo
{
    Float:vehicle_info_x,
    Float:vehicle_info_y,
    Float:vehicle_info_z,
    Float:vehicle_info_angle
};

new aVehicleInfo[MAX_VEHICLES][eVehicleInfo];

// ** MAIN

main()
{
    print("Loaded \"vehicle_angle.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    new vehicleid = AddStaticVehicle(400, 132.1159, -92.7907, 1.5220, 291.6237, 123, 1);

    GetVehiclePos(vehicleid, aVehicleInfo[vehicleid][vehicle_info_x], aVehicleInfo[vehicleid][vehicle_info_y], aVehicleInfo[vehicleid][vehicle_info_z]);
    GetVehicleZAngle(vehicleid, aVehicleInfo[vehicleid][vehicle_info_angle]);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    SetVehiclePos(vehicleid, aVehicleInfo[vehicleid][vehicle_info_x], aVehicleInfo[vehicleid][vehicle_info_y], aVehicleInfo[vehicleid][vehicle_info_z]);

    SetTimerEx("SetVehicleZAngleAfterSpawn", 1500, false, "i", vehicleid);
    return 1;
}

// ** COMMANDS

CMD:respawnvehicles(playerid, params[])
{
    for(new i = 1, j = GetVehiclePoolSize(); i <= j; i ++)
    {
        SetVehicleToRespawn(i);
    }
    return 1;
}

CMD:park(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    GetVehiclePos(vehicleid, aVehicleInfo[vehicleid][vehicle_info_x], aVehicleInfo[vehicleid][vehicle_info_y], aVehicleInfo[vehicleid][vehicle_info_z]);
    GetVehicleZAngle(vehicleid, aVehicleInfo[vehicleid][vehicle_info_angle]);
    return 1;
}

// ** FUNCTIONS

forward SetVehicleZAngleAfterSpawn(vehicleid);
public SetVehicleZAngleAfterSpawn(vehicleid)
{
    SetVehicleZAngle(vehicleid, aVehicleInfo[vehicleid][vehicle_info_angle]);
    return 1;
}
Reply
#7

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
what angle does it set it at? random or 0 ?
does it happen to all vehicles ? idk.. maybe someone else will reply with solution
Well yeah with all vehicles but only if I use SetVehicleToRespawn

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Where exactly are you respawning it?
I got a command which is basically SetVehicleToRespawn(playerid,GetPlayerVehicleID(pl ayerid))

Quote:
Originally Posted by Kevln
Посмотреть сообщение
pawn Код:
// ** INCLUDES

#include <a_samp>
#include <zcmd>

// ** ARRAYS AND ENUMERATORS

enum eVehicleInfo
{
    Float:vehicle_info_x,
    Float:vehicle_info_y,
    Float:vehicle_info_z,
    Float:vehicle_info_angle
};

new aVehicleInfo[MAX_VEHICLES][eVehicleInfo];

// ** MAIN

main()
{
    print("Loaded \"vehicle_angle.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    new vehicleid = AddStaticVehicle(400, 132.1159, -92.7907, 1.5220, 291.6237, 123, 1);

    GetVehiclePos(vehicleid, aVehicleInfo[vehicleid][vehicle_info_x], aVehicleInfo[vehicleid][vehicle_info_y], aVehicleInfo[vehicleid][vehicle_info_z]);
    GetVehicleZAngle(vehicleid, aVehicleInfo[vehicleid][vehicle_info_angle]);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    SetVehiclePos(vehicleid, aVehicleInfo[vehicleid][vehicle_info_x], aVehicleInfo[vehicleid][vehicle_info_y], aVehicleInfo[vehicleid][vehicle_info_z]);

    SetTimerEx("SetVehicleZAngleAfterSpawn", 1500, false, "i", vehicleid);
    return 1;
}

// ** COMMANDS

CMD:respawnvehicles(playerid, params[])
{
    for(new i = 1, j = GetVehiclePoolSize(); i <= j; i ++)
    {
        SetVehicleToRespawn(i);
    }
    return 1;
}

CMD:park(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    GetVehiclePos(vehicleid, aVehicleInfo[vehicleid][vehicle_info_x], aVehicleInfo[vehicleid][vehicle_info_y], aVehicleInfo[vehicleid][vehicle_info_z]);
    GetVehicleZAngle(vehicleid, aVehicleInfo[vehicleid][vehicle_info_angle]);
    return 1;
}

// ** FUNCTIONS

forward SetVehicleZAngleAfterSpawn(vehicleid);
public SetVehicleZAngleAfterSpawn(vehicleid)
{
    SetVehicleZAngle(vehicleid, aVehicleInfo[vehicleid][vehicle_info_angle]);
    return 1;
}
Ill try it out


EDIT: Yeah that works just fine, probably Ill have to do it like this sometimes. Thanks for the help. +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)