SA-MP Forums Archive
Give money for player - 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: Give money for player (/showthread.php?tid=650773)



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:x8Float:y8Float:z8;
                    
GetObjectPos(Object_IDx8y8z8);
                    for(new 
p,j=GetPlayerPoolSize(); <=jp++)
                    {
                        if(!
IsPlayerConnected(p) || IsPlayerNPC(p)) continue;
                        if(
IsPlayerInRangeOfPoint(p7.0x8y8z8)) GivePlayerMoneyA(p150);
                    } 



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: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); 



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.