SA-MP Forums Archive
Randpm Hit - 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: Randpm Hit (/showthread.php?tid=621850)



Randpm Hit - Hunud - 15.11.2016

Ok i amde hit system! No need to post code here!

I just wanna know how to make automatic hit/bounty on player/s every 5 minutes ? I mean server will take player who will be on hit!

Thanks!


Re: Randpm Hit - StrikerZ - 16.11.2016

Use this https://sampwiki.blast.hk/wiki/Random


Re: Randpm Hit - TwinkiDaBoss - 16.11.2016

Code untested.

pawn Код:
new bool:bounty[MAX_PLAYERS] = false;


#define TIME_SET (60*1000)*5 //change 5 to how many minutes u way

SetTimer("randomBounty",TIME_SET,true); //add under OnGameModeInit()


public randomBounty() {
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            if(bounty[i] == false) {
                bounty[i] = true;
                new string[64];
                format(string,sizeof(string),"Bounty is now on %s",GetName(playerid));
                SendClientMessageToAll(COLOR_RED,string);
                break;
            }
        }
    }
}



Re: Randpm Hit - StrikerZ - 16.11.2016

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Code untested.

pawn Код:
new bool:bounty[MAX_PLAYERS] = false;


#define TIME_SET (60*1000)*5 //change 5 to how many minutes u way

SetTimer("randomBounty",TIME_SET,true); //add under OnGameModeInit()


public randomBounty() {
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            if(bounty[i] == false) {
                bounty[i] = true;
                new string[64];
                format(string,sizeof(string),"Bounty is now on %s",GetName(playerid));
                SendClientMessageToAll(COLOR_RED,string);
                break;
            }
        }
    }
}
Shouldn't this be
PHP код:
 format(string,sizeof(string),"Bounty is now on %s",GetName(i)); 



Re: Randpm Hit - TwinkiDaBoss - 16.11.2016

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Shouldn't this be
PHP код:
 format(string,sizeof(string),"Bounty is now on %s",GetName(i)); 
Yep, fucked that one up xD


Re: Randpm Hit - Logic_ - 16.11.2016

You didn't only fuck up with that, you also fucked up with the loop.

Quote:

for(new i = 0; i < MAX_PLAYERS; i++) {

This is more slower and prone to crashes, while
Quote:

for(new i, l = GetPlayerPoolSize(); i <= l; i++)

is faster, better and not prone to crashes. Also, in the first loop you must re-define MAX_PLAYERS as well.