Give money for player -
Foxer123456 - 06.03.2018
hi guys, i want to ask you how to do when player is near object and for example if players destroy some object all players gets money who was near what object.
i doing somethink like this but i get warning all the time with positions.
Код HTML:
error 028: invalid subscript (not an array or too many subscripts): "x8"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
new Float:x8, Float:y8, Float:z8;
GetObjectPos(Object_ID, x8[0], y8[1], z8[2]);
if (IsPlayerInRangeOfPoint(playerid, 7.0, x8[0], y8[1], z8[2]))
{
for(new p; p < MAX_PLAYERS; p++)
{
if(!IsPlayerConnected(p) || IsPlayerNPC(p)) continue;
GivePlayerMoneyA(p, 150);
}
}
error line: GetObjectPos(Object_ID, x8[0], y8[1], z8[2]);
Re: Give money for player -
AroseKhanNiazi - 06.03.2018
PHP код:
new Float:x8, Float:y8, Float:z8;
GetObjectPos(Object_ID, x8, y8, z8);
for(new p,j=GetPlayerPoolSize(); p <=j; p++)
{
if(!IsPlayerConnected(p) || IsPlayerNPC(p)) continue;
if(IsPlayerInRangeOfPoint(p, 7.0, x8, y8, z8)) GivePlayerMoneyA(p, 150);
}
Re: Give money for player -
Foxer123456 - 06.03.2018
thankss.
Re: Give money for player -
Private200 - 06.03.2018
You might get more than one result and thus reward more than one player; so make sure you get the proper distance from point and then compare it with the next value, will be more accurate this way.
PHP код:
new Float:x8, Float:y8, Float:z8, Float:_distMax, _closePlayer;
GetObjectPos(Object_ID, x8, y8, z8);
for(new p,j=GetPlayerPoolSize(); p <=j; p++)
{
if(!IsPlayerConnected(p) || IsPlayerNPC(p)) continue;
if(IsPlayerInRangeOfPoint(p, 7.0, x8, y8, z8)) {
new Float:_distPlayer;
_distPlayer = GetPlayerDistanceFromPoint(p, x8, y8, z8);
if(_distPlayer > _distMax) {
_closePlayer = p;
}
}
}
GivePlayerMoneyA(_closerPlayer, 150);
Re: Give money for player -
AroseKhanNiazi - 06.03.2018
He want's it like that, 'all' he wrote in the first post that everyone should get reward who's in range.
Re: Give money for player -
Private200 - 06.03.2018
I gave the code in case he wants player closest to the point to get the reward, up to him. I might have simply missunderstood it.
Re: Give money for player -
AroseKhanNiazi - 06.03.2018
Ye, well it's always better to know what else he can do

I hope he learns from these codes.