#1

Hey i made a arena command and when someone joins it should send a message to everyone about how much players are in the arena but it doesnt work look

PHP код:
new Participants[MAX_PLAYERS];
new 
bool:InArena[MAX_PLAYERS char];
CMD:arena(playeridparams[])
{
        
InArena[playerid] = true;
        new 
string[90];
        
format(string,sizeof(string),"[ARENA]: %s(%d) has joined The Arena  [%i Participants]",GetName(playerid),Participants);
        
Participants[playerid] ++;
SendClientMessageToAll(-1,string); 
Reply
#2

you have to plus one participant then format the message also you have to put return 1; so it should look like:

PHP код:
new Participants;
CMD:arena(playeridparams[])
{
    new 
string[90];
    
InArena[playerid] = true;
    
Participants++;
    
format(string,sizeof(string),"[ARENA]: %s(%d) has joined The Arena  [%i Participants]",GetName(playerid), playeridParticipants);
    
SendClientMessageToAll(-1,string);
    return 
1;

edit: i dont think you should make arena Participants[MAX_PLAYERS] it should be a normal variable just new Participants because

Participants[MAX_PLAYERS] < one variable for each player so when they join each player variable will count the player itself not other players
Reply
#3

Also your InArena is a char array, you must use {} to access it:
pawn Код:
InArena{playerid} = true;
Reply
#4

Quote:
Originally Posted by lackmail
Посмотреть сообщение
you have to plus one participant then format the message also you have to put return 1; so it should look like:

PHP код:
new Participants;
CMD:arena(playeridparams[])
{
    new 
string[90];
    
InArena[playerid] = true;
    
Participants++;
    
format(string,sizeof(string),"[ARENA]: %s(%d) has joined The Arena  [%i Participants]",GetName(playerid), playeridParticipants);
    
SendClientMessageToAll(-1,string);
    return 
1;

edit: i dont think you should make arena Participants[MAX_PLAYERS] it should be a normal variable just new Participants because

Participants[MAX_PLAYERS] < one variable for each player so when they join each player variable will count the player itself not other players
Thanks.

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Also your InArena is a char array, you must use {} to access it:
pawn Код:
InArena{playerid} = true;
I use that way alot in my script should i change it? also what would happen if i use it with [ instead of {
Reply
#5

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
I use that way alot in my script should i change it? also what would happen if i use it with [ instead of {
Yes, you should change it. You will get out-of-bounds errors and other glitchy behavior if you don't because a char-array is only 1/4th the size of a regular array. A regular array stores one item in one cell, a char array stores four items per cell. Assuming a MAX_PLAYERS setting of 100, a char array of that size will only produce 25 cells. Attempting to use it with a playerid of 25 or higher will yield OOB errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)