for(new i = 0; i < sizeof(myObjArray); i++) { if(IsPlayerNearObject(playerid, myObjArray[i])) { ... } }
if(IsPlayerNearObject(playerid, myObjArray[0]) || IsPlayerNearObject(playerid, myObjArray[1]) || IsPlayerNearObject(playerid, myObjArray[2]) || IsPlayerNearObject(playerid, myObjArray[3]) || IsPlayerNearObject(playerid, myObjArray[4]) || IsPlayerNearObject(playerid, myObjArray[5]) || IsPlayerNearObject(playerid, myObjArray[6]) || IsPlayerNearObject(playerid, myObjArray[7]) || IsPlayerNearObject(playerid, myObjArray[8]) || IsPlayerNearObject(playerid, myObjArray[9])) { ... }
stock IsPlayerNearObject(playerid, objectid, Float:range = 2.0) { new Float:X, Float:Y, Float:Z; GetDynamicObjectPos(objectid, X, Y, Z); if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z)) return 1; else return 0; }
stock IsPlayerNearObject(playerid, objectid, Float:range = 2.0)
{
new Float:X, Float:Y, Float:Z;
GetDynamicObjectPos(objectid, X, Y, Z);
return IsPlayerInRangeOfPoint(playerid, range, X, Y, Z);
}
for(new i = 0; i < sizeof(myObjArray); i++)
{
if(IsPlayerNearObject(playerid, myObjArray[i]))
{
...
}
}
obj[0] = CreateDynamicObject(id, X, Y, Z, 0, 0, 0); obj[1] = CreateDynamicObject(id, X, Y, Z, 0, 0, 0); obj[2] = CreateDynamicObject(id, X, Y, Z, 0, 0, 0); for(new i = 0; i < sizeof(obj); i++) { if(IsPlayerNearObject(playerid, obj[i], 2.0)) { ShowTDActivity(playerid, "Something"); activityTimer[playerid] = SetTimerEx("Something", 1000, true, "i", playerid); } }
So why this doesn't work?
Код:
obj[0] = CreateDynamicObject(id, X, Y, Z, 0, 0, 0); obj[1] = CreateDynamicObject(id, X, Y, Z, 0, 0, 0); obj[2] = CreateDynamicObject(id, X, Y, Z, 0, 0, 0); for(new i = 0; i < sizeof(obj); i++) { if(IsPlayerNearObject(playerid, obj[i], 2.0)) { ShowTDActivity(playerid, "Something"); activityTimer[playerid] = SetTimerEx("Something", 1000, true, "i", playerid); } } |