Problem with playerid - 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: Problem with playerid (
/showthread.php?tid=303925)
Problem with playerid -
[FAT]Klabauter[LST] - 16.12.2011
I'm trying to make a function that will heal a players vehicle while player is in range of point.
My problem is that it only works for id 0, unless I put it under OnPlayerUpdate which i don't wanna do.
Код:
forward repair(playerid);
public OnGameModeInit()
{
SetTimer("repair", 2000, true);
}
public repair(playerid)
{
new Float:x, Float:y, Float:z;
new vehicleid = GetPlayerVehicleID(playerid);
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInVehicle(playerid, vehicleid))
{
if(IsPlayerInRangeOfPoint(playerid, 650.0, -1171.4510, -226.3357, 14.1484))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(playerid, 150.0, 1977.5227, -2352.5647, 13.1115))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(playerid, 150.0, 1757.5624, -2536.8030, 13.1132))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(playerid, 150.0, 1972.2734, -2527.6707, 13.1140))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(playerid, 150.0, 1490.7642, -2510.8005, 13.1258))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(playerid, 100.0, 1724.5593, -2275.1589, 61.8035))
{
SetVehicleHealth(vehicleid, 1000.0);
}
}
return 1;
}
Can anyone help me out?
Thanks
Re: Problem with playerid -
PrawkC - 16.12.2011
use a for loop in the repair function
Re: Problem with playerid -
kizla - 16.12.2011
pawn Код:
public repair(playerid)
{
new Float:x, Float:y, Float:z;
new vehicleid = GetPlayerVehicleID(playerid);
GetPlayerPos(playerid, x, y, z);
for(new i = 0; i < MAX_PLAYERS;i++)
{
if(IsPlayerInVehicle(i, vehicleid))
{
if(IsPlayerInRangeOfPoint(i, 650.0, -1171.4510, -226.3357, 14.1484))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(i, 150.0, 1977.5227, -2352.5647, 13.1115))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(i, 150.0, 1757.5624, -2536.8030, 13.1132))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(i, 150.0, 1972.2734, -2527.6707, 13.1140))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(i, 150.0, 1490.7642, -2510.8005, 13.1258))
{
SetVehicleHealth(vehicleid, 1000.0);
}
if(IsPlayerInRangeOfPoint(i, 100.0, 1724.5593, -2275.1589, 61.8035))
{
SetVehicleHealth(vehicleid, 1000.0);
}
}
}
return 1;
}
here you go
Re: Problem with playerid -
[FAT]Klabauter[LST] - 16.12.2011
Thanks for helping but unfortunately it is still only working for id 0