House Checkpoint - 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: House Checkpoint (
/showthread.php?tid=568471)
House Checkpoint -
Chrillzen - 22.03.2015
Alright, the code below works but only for the first house. The checkpoint only appears for the first house in the script. Can someone tell me what I'm doing wrong?
pawn Код:
for(new h = 1; h < sizeof(HouseInfo); h++)
{
if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ]))
{
HouseInfo[h][HouseCP] = CreateDynamicCP(HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ], 1.5, -1, -1, playerid, 5.0);
return 1;
}
else
{
DestroyDynamicCP(HouseInfo[h][HouseCP]);
return 1;
}
}
Re: House Checkpoint -
LetsOWN[PL] - 22.03.2015
Quote:
Originally Posted by Chrillzen
Alright, the code below works but only for the first house. The checkpoint only appears for the first house in the script. Can someone tell me what I'm doing wrong?
pawn Код:
for(new h = 1; h < sizeof(HouseInfo); h++) { if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ])) { HouseInfo[h][HouseCP] = CreateDynamicCP(HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ], 1.5, -1, -1, playerid, 5.0); return 1; } else { DestroyDynamicCP(HouseInfo[h][HouseCP]); return 1; } }
|
Hello there.
Everything, besides that h should be 0 (because indexes starts from 0) at the declaration of the loop (or h=1 for some purpose, I don't know), seems to be okay.
So, what You've shown us here is actually allright. The problem might be in the way you load coordinates to HouseInfo enumerator. Could You show us how do you load
data to it? Otherwise, noone will be able to help you..
Greetings!
Re: House Checkpoint -
Chrillzen - 22.03.2015
pawn Код:
public loadhouse_data(idx, name[], value[])
{
INI_Int("hHouseCP", HouseInfo[idx][HouseCP]);
return 1;
}
enum hInfo
{
HouseCP
}
Re: House Checkpoint -
Evocator - 22.03.2015
Dynamic CPs are "dynamic". Therefor why not creating them all as they only stream for near players and avoid all of this?
Respuesta: House Checkpoint -
alexus - 22.03.2015
The problem is the return 1; inside the loop. Delete it
Код:
for(new h = 1; h < sizeof(HouseInfo); h++)
{
if(IsPlayerInRangeOfPoint(playerid, 10.0, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ]))
{
HouseInfo[h][HouseCP] = CreateDynamicCP(HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ], 1.5, -1, -1, playerid, 5.0);
break;
}
else DestroyDynamicCP(HouseInfo[h][HouseCP]);
}
Re: House Checkpoint -
Chrillzen - 22.03.2015
Thanks guys, I haven't been scripting for a while so I'm quite rusty.