Raised This Month: $ Target: $400
 0% 

Event on player count


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-30-2006 , 16:13   Event on player count
Reply With Quote #1

Hi i made a plugin that turns alltalk on and off, reacting on how many players on the server.

I made it with a cvar put in amxx.cfg, so users of the plugin can put in the number of users they want to.

In my code it is set to 4, and it works nicely when player number 5 joins, it turns off all talk, but when player 5 disconnects alltalk dont come back on.

Here is my code:
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "AutoAllTalk" #define VERSION "1.1" #define AUTHOR "Lone Wolf" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_logevent("roundstart", 2, "0=World triggered", "1=Round_Start") } public roundstart() {     set_task(1.0, "set_NewAlltalk") } public client_connect(id) {     set_task(1.0, "set_NewAlltalk") } public client_disconnect(id) {     set_task(1.0, "set_NewAlltalk") } public set_NewAlltalk(taskId) {     new tmpPlayer     new tmpCount     tmpPlayer = get_cvar_num("amx_nrPlayer")     tmpCount = get_playersnum(1)     if (tmpCount==tmpPlayer) {         set_cvar_num("sv_alltalk",1)     }     else if (tmpCount==(tmpPlayer+1)) {         set_cvar_num("sv_alltalk",0)     } }

I also tried using plugin_init() instead of roundstart, but that didnt seem to work either, i removed that because i wasnt sure if plugin_init is run on reload or mapchange......

Hope someone can se the error

/Lone Wolf
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-30-2006 , 16:18  
Reply With Quote #2

On client disconnect, check how many players there are then if its less than the cvar, turn alltalk to 0.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-30-2006 , 18:01  
Reply With Quote #3

If the cvar is 4, it should set alltalk 1, so when a client disconnects and number of players is equal or less than 4 it should set it.....

as far as i can see it is what i have coded.....or have i overlooked something ?


Code:
public set_NewAlltalk(taskId) {     new tmpPlayer     new tmpCount     tmpPlayer = get_cvar_num("amx_nrPlayer")     tmpCount = get_playersnum(1)     if (tmpCount<=tmpPlayer) {         set_cvar_num("sv_alltalk",1)     }     else if (tmpCount>=(tmpPlayer+1)) {         set_cvar_num("sv_alltalk",0)     } }

Or something like that ?
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-30-2006 , 21:31  
Reply With Quote #4

is amx_nrPlayer a default cvar?
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-30-2006 , 21:49  
Reply With Quote #5

It is one i put in amxx.cfg, not a default amx cvar.
I figured i dint have to register it, when it is put in....

But maby thats the error?

/Lone Wolf
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-30-2006 , 22:01  
Reply With Quote #6

Look below at the updated code.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-30-2006 , 22:08  
Reply With Quote #7

Ill try

But one thing i dont understand, why this:
Code:
tempPlay = register_cvar("amx_how_many", "4")

And by doing that, can a user change the number to react on ?
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-30-2006 , 22:17  
Reply With Quote #8

This is used to register the cvar for how many players..


And yes, you use this line in console:

Code:
amx_cvar amx_how_many number
if amx_how_many is set to 5 and there are 5 or fewer people in the server, alltalk will be on.. if amx_how_many is set to 5 and there are 6 or more people in the server, it will turn off.

Heres some updated code.

Code:
#include <amxmodx> #include <amxmisc> new tempPlay public plugin_init() {     register_plugin("AutoAllTalk","1.1","Lone Wolf")     register_logevent("roundstart", 2, "0=World triggered", "1=Round_Start")     tempPlay = register_cvar("amx_how_many","4") } public roundstart(id) {     set_NewAlltalk(id) } public client_connect(id) {     set_NewAlltalk(id) } public client_disconnect(id) {     set_NewAlltalk(id) } public set_NewAlltalk(id) {     new tmpPlayer = get_pcvar_num(tempPlay)     new tmpCount = get_playersnum(1)     if(tmpCount <= tmpPlayer)     {         set_cvar_num("sv_alltalk",1)     }     else     {         set_cvar_num("sv_alltalk",0)     } }
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-30-2006 , 22:33  
Reply With Quote #9

You get that ok?
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 06-25-2006 , 04:17   Re: Event on player count
Reply With Quote #10

Sorry for the wait, my computer crashed.....

And thanks a lot for the help it works nicely
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
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

Forum Jump


All times are GMT -4. The time now is 16:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode