/autostop
#1

Hi peoples. I need some help. I want to do that thing if player in car is 10 metres from other car,then he get stopped,i try to something:

Код:
forward OnPlayerUpdate(playerid);
public OnPlayerUpdate(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new Float:Coord[3];
GetVehiclePos(i, Coord[0], Coord[1], Coord[2]);
if(IsPlayerConnected(i))
{
if(i != playerid)
{
if(IsPlayerInRangeOfPoint(i, 10.0, Coord[0], Coord[1], Coord[2]))
{
GameTextForPlayer(playerid,"~r~Car in way!",3000,5);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.0, 0.0);
}
}
}
}
But this not work...
Reply
#2

1) You are forwarding already made callback = Wrong.
2) You are making loop with number of max players to check all vehicles and then you check is that vehicle connected () and then you check is vehicle id different from player id and then with same loop you used to get vehicle that are connected you are checking is player id with vehicle id in range of point.

Try to fix those and it might work
Reply
#3

What is here wrong?

Код:
for(new i = 0; i < MAX_VEHICLES; i++)
{
new Float:Coord[3];
new vehicleid = GetPlayerVehicleID(i);
new myvehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(i, Coord[0], Coord[1], Coord[2]);
if(myvehicleid != vehicleid)
{
if(IsPlayerInRangeOfPoint(playerid, 10.0, Coord[0], Coord[1], Coord[2]))
{
GameTextForPlayer(playerid,"~r~Car in way!",3000,5);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.0, 0.0);
}
}
}
Reply
#4

first of all you dont need to forward
pawn Код:
OnPlayerUpdate
fuction because it is already a callback on sa-mp ...
Reply
#5

Please not off topic with that problem,i ask what wrong in code,not about onplayerupdate....
Reply
#6

Thats wrong! You cant call something that's already made. Also if you want help stop to act arrogant
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)