Help objects - 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: Help objects (
/showthread.php?tid=510110)
Help objects -
ShoortyFl - 29.04.2014
I've been doing on some farm job sys. and everything works but this function
Код:
if(FarmActive[playerid] == 1)
{
for(new id = 0; id < createdobjects[playerid]; id++)
{
new Float:Pos[3];
GetDynamicObjectPos(farmobject[playerid][id], Pos[0], Pos[1], Pos[2]);
if(!IsPlayerInRangeOfPoint(playerid, 3.0, Pos[0], Pos[1], Pos[2])) return SCM(playerid, TOMATO, " (greska) You're not near-by the farm object !");
SetPlayerAttachedObject(playerid, 0, 2901, 1, -0.022000, -0.212999, -0.007000, 0.000000, -2.099999, -2.599998, 0.612999, 0.439000, 0.607999, 0, 0);
SCM(playerid, YELLOW, " (info) Executed !");
DestroyDynamicObject(farmobject[playerid][id]);
createdobjects[playerid] --;
}
}
it just wont work, it says im not near the object when im standing in it
Re: Help objects -
ShoortyFl - 29.04.2014
anyone ?
Re: Help objects -
ShoortyFl - 30.04.2014
can anyone help me please ?
Re: Help objects -
Vince - 30.04.2014
I don't know to how many people I've said this already: NEVER return inside a loop unless you explicitly want to break it!
Re: Help objects -
Konstantinos - 30.04.2014
Your code only checks if you're not near the first created object and not the rest.
pawn Код:
if(FarmActive[playerid] == 1)
{
new Float:Pos[3], obj_slot = -1;
for(new id = 0; id < createdobjects[playerid]; id++)
{
GetDynamicObjectPos(farmobject[playerid][id], Pos[0], Pos[1], Pos[2]);
if(IsPlayerInRangeOfPoint(playerid, 3.0, Pos[0], Pos[1], Pos[2]))
{
obj_slot = id;
}
}
if (obj_slot != -1)
{
SetPlayerAttachedObject(playerid, 0, 2901, 1, -0.022000, -0.212999, -0.007000, 0.000000, -2.099999, -2.599998, 0.612999, 0.439000, 0.607999, 0, 0);
SCM(playerid, YELLOW, " (info) Executed !");
DestroyDynamicObject(farmobject[playerid][obj_slot]);
createdobjects[playerid] --;
}
else return SCM(playerid, TOMATO, " (greska) You're not near-by the farm object !");
}
Re: Help objects -
ShoortyFl - 30.04.2014
Again, i put it like this and it wont work
Код:
if(SemePreradjeno[playerid] == 1)
{
new Float:Pos[3], obj_slot = -1;
for(new id = 0; id < 10; id++)
{
GetDynamicObjectPos(farmerobjekt[playerid][id], Pos[0], Pos[1], Pos[2]);
if(IsPlayerInRangeOfPoint(playerid, 3.0, Pos[0], Pos[1], Pos[2]))
{
obj_slot = id;
}
}
if (obj_slot != -1)
{
SetPlayerAttachedObject(playerid, 0, 2901, 1, -0.022000, -0.212999, -0.007000, 0.000000, -2.099999, -2.599998, 0.612999, 0.439000, 0.607999, 0, 0);
SCM(playerid, YELLOW, " (info) Uzeli ste preradjeno zito, odnesite ga u staju !");
DestroyDynamicObject(farmerobjekt[playerid][obj_slot]);
kreiranihobjekata[playerid] --;
}
else return SCM(playerid, TOMATO, " (greska) Ne nalazite se blizu vaseg useva !");
}
}
Re: Help objects -
ShoortyFl - 30.04.2014
Anyone ?