How to make a max event players.
#1

Hello, I've been working on an event system and I was going to add an MAX EVENT PLAYERS in to stop the event from getting overfull, so this is what I tried:

Code:
#define MAX_EVENT_PLAYERS 16
pawn Code:
CMD:event(playerid, params[])
{
    if(EventOn == false)
    {
        SendClientMessage(playerid, red, "There is no event on.");
    }
    else
    if(EventPlayer[playerid] == true)
    {
        SendClientMessage(playerid, red, "You are already on the event.");
    }
    else
    if(EventStarted == true)
    {
        SendClientMessage(playerid, red, "Event has started.");
    }
    else
    if(GetMaxPlayers() > MAX_EVENT_PLAYERS)
    {
        SendClientMessage(playerid, red, "Event is full.");
    }
    else
    {
        EventPlayer[playerid] = true;
        SendClientMessage(playerid, orange, "You joined event.");
        GivePlayerMoney(playerid, -10000);
        GetPlayerPos(playerid, eX, eY, eZ);
        SetPlayerPos(playerid, -384.3118,-3006.7292,101.2255);
    }
    return 1;
}
If you know where I am going wrong, please help! thanks.
Reply
#2

Quote:
Originally Posted by LeXuZ
View Post
Hello, I've been working on an event system and I was going to add an MAX EVENT PLAYERS in to stop the event from getting overfull, so this is what I tried:

Code:
#define MAX_EVENT_PLAYERS 16
pawn Code:
CMD:event(playerid, params[])
{
    if(EventOn == false)
    {
        SendClientMessage(playerid, red, "There is no event on.");
    }
    else
    if(EventPlayer[playerid] == true)
    {
        SendClientMessage(playerid, red, "You are already on the event.");
    }
    else
    if(EventStarted == true)
    {
        SendClientMessage(playerid, red, "Event has started.");
    }
    else
    if(GetMaxPlayers() > MAX_EVENT_PLAYERS)
    {
        SendClientMessage(playerid, red, "Event is full.");
    }
    else
    {
        EventPlayer[playerid] = true;
        SendClientMessage(playerid, orange, "You joined event.");
        GivePlayerMoney(playerid, -10000);
        GetPlayerPos(playerid, eX, eY, eZ);
        SetPlayerPos(playerid, -384.3118,-3006.7292,101.2255);
    }
    return 1;
}
If you know where I am going wrong, please help! thanks.
GetMaxPlayers is to get the max amount of players that can enter the server,add this:
pawn Code:
new EventPlayers;
And change the command to:
pawn Code:
CMD:event(playerid, params[])
{
    if(EventOn == false)
    {
        SendClientMessage(playerid, red, "There is no event on.");
    }
    else
    if(EventPlayer[playerid] == true)
    {
        SendClientMessage(playerid, red, "You are already on the event.");
    }
    else
    if(EventStarted == true)
    {
        SendClientMessage(playerid, red, "Event has started.");
    }
    else
    if(EventPlayers > MAX_EVENT_PLAYERS)
    {
        SendClientMessage(playerid, red, "Event is full.");
    }
    else
    {
        EventPlayer[playerid] = true;
        SendClientMessage(playerid, orange, "You joined event.");
        GivePlayerMoney(playerid, -10000);
        GetPlayerPos(playerid, eX, eY, eZ);
        SetPlayerPos(playerid, -384.3118,-3006.7292,101.2255);
                EventPlayers++;
    }
    return 1;
}
Reply
#3

Code:
new MAX_EVENT_PLAYERS = 0;
Code:
	        if(MaxPlayerEvent < MAX_EVENT_PLAYERS)
	        {
			    SendClientMessages(playerid, -1, "you entered the event.");
			    MAX_EVENT_PLAYERS++;
		}
		else
		{
			   SendClientMessages(playerid, -1, "Event is full.");
		}
Reply
#4

Quote:
Originally Posted by R0
View Post
GetMaxPlayers is to get the max amount of players that can enter the server,add this:
pawn Code:
new EventPlayers;
And change the command to:
pawn Code:
CMD:event(playerid, params[])
{
    if(EventOn == false)
    {
        SendClientMessage(playerid, red, "There is no event on.");
    }
    else
    if(EventPlayer[playerid] == true)
    {
        SendClientMessage(playerid, red, "You are already on the event.");
    }
    else
    if(EventStarted == true)
    {
        SendClientMessage(playerid, red, "Event has started.");
    }
    else
    if(EventPlayers > MAX_EVENT_PLAYERS)
    {
        SendClientMessage(playerid, red, "Event is full.");
    }
    else
    {
        EventPlayer[playerid] = true;
        SendClientMessage(playerid, orange, "You joined event.");
        GivePlayerMoney(playerid, -10000);
        GetPlayerPos(playerid, eX, eY, eZ);
        SetPlayerPos(playerid, -384.3118,-3006.7292,101.2255);
                EventPlayers++;
    }
    return 1;
}
I added what you said too and this showed up:
Code:
[15:31:47] Event has started.
[15:31:54] Warning: client exceeded 'messageholelimit' (1) 192.168.0.3:55645 (4463) Limit: 3000
Reply
#5

Test it again
Reply
#6

Same problem...
Reply
#7

Oh, sorry, that wasn't part of the code that you helped me with. It was a loop that seem to be making the server crash, can someone check on this? I don't seem to find out how to make a moving object loop...
pawn Code:
for(new i = 1; i>0; i++)
    {
    MoveObject(EventMovingObject1, -376.54391, -3023.34253, 100.15520, 2.00);
    MoveObject(EventMovingObject2, -372.61630, -2989.47656, 100.15520, 2.00);
    MoveObject(EventMovingObject3, -368.63959, -3023.34253, 100.15520, 2.00);
    MoveObject(EventMovingObject4, -364.60791, -2989.47656, 100.15520, 2.00);
    MoveObject(EventMovingObject5, -360.65991, -3023.34253, 100.15520, 2.00);
    MoveObject(EventMovingObject6, -356.73599, -2989.47656, 100.15520, 2.00);
    MoveObject(EventMovingObject7, -352.83591, -3023.34253, 100.15520, 2.00);
    MoveObject(EventMovingObject8, -348.85791, -2989.47656, 100.15520, 2.00);
    MoveObject(EventMovingObject9, -344.91891, -3023.34253, 100.15520, 2.00);
    }
I have no idea on how to make loops, always a good time to learn, huh
Reply
#8

By the way the code i gave you should work.
Well,you didnt use any "i" that you have looped in there,you can find more information about the loops here:
https://sampwiki.blast.hk/wiki/Loops
And by the way you dont have to use loops in the code u just showed,because the moving coords are different to each object,so remove that loop,and it will work

Note:If you want me to post an example of moving objects with a loop then reply.
Reply
#9

Yeah, I've already checked there, plus, the moving objects only go one way, I wanted them to move forwards and backwards until the event has came to a finish, if you get what I mean, thanks for helping and if you know how I could do it, please reply!
Reply
#10

Hello!

PHP Code:
for(new 1i>0i++) 
It is an endless loop, because i is always higher than 0.
Write your code so that's enough so or not?

PHP Code:
MoveObject(EventMovingObject1, -376.54391, -3023.34253100.155202.00);
MoveObject(EventMovingObject2, -372.61630, -2989.47656100.155202.00);
MoveObject(EventMovingObject3, -368.63959, -3023.34253100.155202.00);
MoveObject(EventMovingObject4, -364.60791, -2989.47656100.155202.00);
MoveObject(EventMovingObject5, -360.65991, -3023.34253100.155202.00);
MoveObject(EventMovingObject6, -356.73599, -2989.47656100.155202.00);
MoveObject(EventMovingObject7, -352.83591, -3023.34253100.155202.00);
MoveObject(EventMovingObject8, -348.85791, -2989.47656100.155202.00);
MoveObject(EventMovingObject9, -344.91891, -3023.34253100.155202.00); 
Mencent
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)