Unmovable vehicle [REP++]
#1

Hi guys , i made a showroom for my server with a lot of cars but my next problem is that players can move them away.
So i tried to make a timer who checks if vehicle pos coresponds with the vehicle pos from database but it's not working.
pawn Код:
public DealerCars()
{
        new Float:x, Float:y, Float:z;
        new vehpos = GetVehiclePos(320, x, y, z);
        if(1043.8596,1586.1318,-17.1108 != vehpos)
        {
            SetVehicleToRespawnEx(320);
        }
}
320 - vehicle id from my sql db, and the coordinates are the 320 car's coordinates.
Reply
#2

you can't put a callback in the script and leave it without a calling function.. it's like nothing in the script.
use a timer, callback function that is called by the timer it's self.
pawn Код:
new vtimer;
public OnGameModeInit()
{
     vtimer = SetTimer("Dealercars", 100, true); // this timer for the dealercars callback, per 100 ms, and repeatable.
     return 1;
}
pawn Код:
public OnGameModeExit
{
     KillTimer(vtime);
     return 1;
}
Reply
#3

Create a timer which works each 1 second
Reply
#4

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
you can't put a callback in the script and leave it without a calling function.. it's like nothing in the script.
use a timer, callback function that is called by the timer it's self.
pawn Код:
new vtimer;
public OnGameModeInit()
{
     vtimer = SetTimer("Dealercars", 100, true); // this timer for the dealercars callback, per 100 ms, and repeatable.
     return 1;
}
pawn Код:
public OnGameModeExit
{
     KillTimer(vtime);
     return 1;
}
I did what you said but not working.. still i can move cars and them are not respawning.., probably public Dealercars() is wrong?
Reply
#5

Oh, just forgot this:
pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
    if(vehicleid == 320)
    {
           new Float:X, Float:Y, Float:Z;
           GetVehiclePos(320, X, Y, Z);
           if(X != new_x || Y != new_y || Z != new_z) return 0;
     }
     return 1;
}
Try it
Reply
#6

Your vehicles have id
In "OnPlayerStateChange" callback Make a loop between vehicle ids and check if a player entered that vehicle ids remove him from vehicle !
Reply
#7

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
Oh, just forgot this:
pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
    if(vehicleid == 320)
    {
           new Float:X, Float:Y, Float:Z;
           GetVehiclePos(320, X, Y, Z);
           if(X != new_x || Y != new_y || Z != new_z) return 0;
     }
     return 1;
}
Try it
Still not working! The car isn't respawn!
Reply
#8

I tried something like this:
pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
    if(vehicleid == 320)
    {
           new Float:X, Float:Y, Float:Z;
           GetVehiclePos(320, X, Y, Z);
           if(X != 1043.8596 || Y != 1586.1318 || Z != -17.1108) return SetVehicleToRespawnEx(320);
     }
     return 1;
}
but nothing.
Reply
#9

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
Oh, just forgot this:
pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
    if(vehicleid == 320)
    {
           new Float:X, Float:Y, Float:Z;
           GetVehiclePos(320, X, Y, Z);
           if(X != new_x || Y != new_y || Z != new_z) return 0;
     }
     return 1;
}
Try it
I tried something like this:
pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
    if(vehicleid == 285)
    {
           new Float:X, Float:Y, Float:Z;
           GetVehiclePos(285, X, Y, Z); // tried with another vehicle
           if(X != 1043.8596)
           {
                SetVehicleToRespawnEx(285);
           }
     }
}
But nothing happens , the car isn't respawning , doh ..
Any ideeas !? Thanks.
Reply
#10

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
Oh, just forgot this:
pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
    if(vehicleid == 320)
    {
           new Float:X, Float:Y, Float:Z;
           GetVehiclePos(320, X, Y, Z);
           if(X != new_x || Y != new_y || Z != new_z) return 0;
     }
     return 1;
}
Try it
Tried your method too but not working... nothing happenss
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)