SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/04/2015, 02:10 PM   #1
LeXuZ
Huge Clucker
 
Join Date: Oct 2014
Location: United Kingdom
Posts: 302
Reputation: 12
Default How to make a max event players.

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.
LeXuZ is offline   Reply With Quote
Old 09/04/2015, 02:16 PM   #2
R0
Big Clucker
 
R0's Avatar
 
Join Date: May 2014
Location: Nowhere,But still you can find me anytime you want
Posts: 140
Reputation: 33
Default Re: How to make a max event players.

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;
}
R0 is offline   Reply With Quote
Old 09/04/2015, 02:16 PM   #3
TazmaNiax
Big Clucker
 
TazmaNiax's Avatar
 
Join Date: Apr 2014
Location: Indonesia
Posts: 134
Reputation: 8
Default Re: How to make a max event players.

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.");
		}
__________________
nope
TazmaNiax is offline   Reply With Quote
Old 09/04/2015, 02:33 PM   #4
LeXuZ
Huge Clucker
 
Join Date: Oct 2014
Location: United Kingdom
Posts: 302
Reputation: 12
Default Re: How to make a max event players.

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
LeXuZ is offline   Reply With Quote
Old 09/04/2015, 02:40 PM   #5
ATGOggy
Gangsta
 
Join Date: Sep 2014
Location: Ls-rcr
Posts: 850
Reputation: 52
Default Re: How to make a max event players.

Test it again
__________________
******: "I've said this before. People think that MySQL is some simple plug-and-play magic bullet that you can use to just make your mode instantly better. They don't realise that the "L" in "SQL" means "language". So instead of programming PAWN, and using a bit of this mystery thing, you are now programming in two languages at once. If you spend months learning PAWN, you should spend the same time learning SQL, if not more - it is probably the more complex of the two languages, and not something that just gets bolted on to the side."


I give and want only fair reps. I hate this: "hey bro, I rep you, rep me plz

Click below if you wanna be amazed:
http://Paid2Refer.com/ref.php?refId=291262
ATGOggy is offline   Reply With Quote
Old 09/04/2015, 04:05 PM   #6
LeXuZ
Huge Clucker
 
Join Date: Oct 2014
Location: United Kingdom
Posts: 302
Reputation: 12
Default Re: How to make a max event players.

Same problem...
LeXuZ is offline   Reply With Quote
Old 09/04/2015, 06:34 PM   #7
LeXuZ
Huge Clucker
 
Join Date: Oct 2014
Location: United Kingdom
Posts: 302
Reputation: 12
Default Re: How to make a max event players.

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
LeXuZ is offline   Reply With Quote
Old 09/04/2015, 06:42 PM   #8
R0
Big Clucker
 
R0's Avatar
 
Join Date: May 2014
Location: Nowhere,But still you can find me anytime you want
Posts: 140
Reputation: 33
Default Re: How to make a max event players.

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:
http://wiki.sa-mp.com/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.
R0 is offline   Reply With Quote
Old 09/04/2015, 07:59 PM   #9
LeXuZ
Huge Clucker
 
Join Date: Oct 2014
Location: United Kingdom
Posts: 302
Reputation: 12
Default Re: How to make a max event players.

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!
LeXuZ is offline   Reply With Quote
Old 09/04/2015, 08:03 PM   #10
Mencent
High-roller
 
Mencent's Avatar
 
Join Date: Mar 2015
Location: Lower Saxony (Niedersachsen)
Posts: 1,311
Reputation: 92
Default AW: How to make a max event players.

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
Mencent is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Give Car Event Players +REP HydraHumza Scripting Help 2 30/01/2015 09:13 AM
How to make /event start an actual event Snowman12 Help Archive 7 03/04/2011 11:39 PM
When players die in a event, they get sent to the hospital? Mr. Despair Help Archive 10 07/01/2011 10:20 AM
Players go to the hospital when they die in a event Mr. Despair Help Archive 6 04/01/2011 02:17 AM
Players go to the hospital when they die in a event Mr. Despair Help Archive 0 17/08/2010 06:15 PM


All times are GMT. The time now is 09:05 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.