PDA

View Full Version : Closest dynamic object


TwinkiDaBoss
07/12/2015, 08:24 PM
Alright so the problem is quite simple, it wont detect when you are near some atm

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
new Atm_Object[8];
Then later on Ive created them under gamemode init (dynamicobjects)

Vince
07/12/2015, 08:28 PM
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.

Patrick
07/12/2015, 08:28 PM
I see that you're using GetObjectPos instead of GetDynamicObjectPos


native GetDynamicObjectPos(STREAMER_TAG_OBJECT objectid, &Float:x, &Float:y, &Float:z);

TwinkiDaBoss
07/12/2015, 08:47 PM
I see that you're using GetObjectPos instead of GetDynamicObjectPos


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

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

Jefff
07/12/2015, 08:53 PM
if(IsValidDynamicObject(Atm_Object[i]))

TwinkiDaBoss
07/12/2015, 08:58 PM
if(IsValidDynamicObject(Atm_Object[i]))

Actually thats it, thanks rep+