Give money for player
#1

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]);
Reply
#2

PHP код:
                    new Float:x8Float:y8Float:z8;
                    
GetObjectPos(Object_IDx8y8z8);
                    for(new 
p,j=GetPlayerPoolSize(); <=jp++)
                    {
                        if(!
IsPlayerConnected(p) || IsPlayerNPC(p)) continue;
                        if(
IsPlayerInRangeOfPoint(p7.0x8y8z8)) GivePlayerMoneyA(p150);
                    } 
Reply
#3

thankss.
Reply
#4

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:x8Float:y8Float:z8Float:_distMax_closePlayer;
                    
GetObjectPos(Object_IDx8y8z8);
                    for(new 
p,j=GetPlayerPoolSize(); <=jp++)
                    {
                        if(!
IsPlayerConnected(p) || IsPlayerNPC(p)) continue;
                        if(
IsPlayerInRangeOfPoint(p7.0x8y8z8)) {
                             new 
Float:_distPlayer;
                             
_distPlayer GetPlayerDistanceFromPoint(px8y8z8);
                             if(
_distPlayer _distMax) {
                                  
_closePlayer p;
                             }
                        }
                    }
                    
GivePlayerMoneyA(_closerPlayer150); 
Reply
#5

He want's it like that, 'all' he wrote in the first post that everyone should get reward who's in range.
Reply
#6

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.
Reply
#7

Ye, well it's always better to know what else he can do I hope he learns from these codes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)