Closest dynamic object - 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: Closest dynamic object (
/showthread.php?tid=595784)
Closest dynamic object -
TwinkiDaBoss - 07.12.2015
Alright so the problem is quite simple, it wont detect when you are near some atm
PHP код:
format(string,sizeof(string),"You have withdrawn %i$ into your bank account. You have %i$ in your bank now",ammount,AccInfo[playerid][BankMoney]);
for(new i = 0; i < sizeof(Atm_Object); i++) {
if(IsValidDynamicObject(i)) {
GetDynamicObjectPos(Atm_Object[i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid, 5.0, x,y,z)) {
GivePlayerCash(playerid,ammount);
AccInfo[playerid][BankMoney] -= ammount;
}
}
}
SendClientMessage(playerid,COLOR_GREEN,string);
Object creation
PHP код:
new Atm_Object[8];
Then later on Ive created them under gamemode init (dynamicobjects)
Re: Closest dynamic object -
Vince - 07.12.2015
Dynamic objects are player object so you should probably use GetPlayerObjectPos. If that doesn't work you may also try Streamer_GetFloatData. Also there is Streamer_IsItemVisible and Streamer_GetDistanceToItem.
Re: Closest dynamic object - Patrick - 07.12.2015
I see that you're using
GetObjectPos instead of
GetDynamicObjectPos
pawn Код:
native GetDynamicObjectPos(STREAMER_TAG_OBJECT objectid, &Float:x, &Float:y, &Float:z);
Re: Closest dynamic object -
TwinkiDaBoss - 07.12.2015
Quote:
Originally Posted by Patrick
I see that you're using GetObjectPos instead of GetDynamicObjectPos
pawn Код:
native GetDynamicObjectPos(STREAMER_TAG_OBJECT objectid, &Float:x, &Float:y, &Float:z);
|
Yeah I forgot to edit the thread, Ive fixed that, but still the issue remains
Quote:
Originally Posted by Vince
Dynamic objects are player object so you should probably use GetPlayerObjectPos. If that doesn't work you may also try Streamer_GetFloatData. Also there is Streamer_IsItemVisible and Streamer_GetDistanceToItem.
|
Ill try it out and post results if I fail or succeed
Re: Closest dynamic object -
Jefff - 07.12.2015
pawn Код:
if(IsValidDynamicObject(Atm_Object[i]))
Re: Closest dynamic object -
TwinkiDaBoss - 07.12.2015
Quote:
Originally Posted by Jefff
pawn Код:
if(IsValidDynamicObject(Atm_Object[i]))
|
Actually thats it, thanks rep+