/autostop - 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: /autostop (
/showthread.php?tid=294572)
/autostop -
budelis - 02.11.2011
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...
Re: /autostop -
[MG]Dimi - 02.11.2011
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
Re: /autostop -
budelis - 02.11.2011
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);
}
}
}
Re: /autostop -
vassilis - 02.11.2011
first of all you dont need to forward
fuction because it is already a callback on sa-mp ...
Re: /autostop -
budelis - 02.11.2011
Please not off topic with that problem,i ask what wrong in code,not about onplayerupdate....
Re: /autostop -
[MG]Dimi - 03.11.2011
Thats wrong! You cant call something that's already made. Also if you want help stop to act arrogant