Randpm Hit
#1

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!
Reply
#2

Use this https://sampwiki.blast.hk/wiki/Random
Reply
#3

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;
            }
        }
    }
}
Reply
#4

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)