Raised This Month: $51 Target: $400
 12% 

Find out if its 4 or less persons left ingame


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 06-21-2005 , 08:10   Find out if its 4 or less persons left ingame
Reply With Quote #1

Ok I need find out when its 4 or less persons alive.

In my case, everybody got godmode, and when its 4 or less persons left, their godmode will go off. (Its for surf maps....)

So how do I code this?
XunTric is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 06-21-2005 , 08:21  
Reply With Quote #2

This is how I do it in one of my plugins:
Code:
public players_num() {     new players[32],num     get_players(players,num)     return num; }

Then in your own function:
Code:
public check_players() {     if(players_num() < 4)     {         // ...     }     return 1; }

Then just set a looping task in the plugin_init:
Code:
public plugin_init() {     // ...     set_task(0.5,"check_players",_,_,_,"b") }

Of course, you don't NEED to make a seperate function to get the # of players, I just did that in my plugin so I could just call that instead of having to get the players each time.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 06-21-2005 , 08:37  
Reply With Quote #3

So like...
Code:
public check_players() {     if(players_num() < 4)     {         client_print(0, print_center, "--- 4 or less players are alive. You can now kill. ---")         client_print(0, print_chat, "--- 4 or less players are alive. You can now kill. ---")         //Is it right to set 0 as index here?         set_user_godmode(0, 0)     }     return 1; }

or?
XunTric is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 06-21-2005 , 08:58  
Reply With Quote #4

Hmm.. I kinda took over ( he wanted me to do it in the beginning anyway, I tried, and failed ).. Also I heard he still wanted fall damage. Hopefully this one will be correct:

Code:
#include <amxmodx> #include <fun> #define TASK_ID 9238    // Task ID #define MIN_PPL 4   // Minimum amount of players #define PLUGIN  "No kill until.." #define VERSION "0.1" #define AUTHOR  "v3x" public plugin_init() {     register_plugin(PLUGIN,VERSION,AUTHOR)     register_event("ResetHUD","new_round","b")     set_task(0.5,"check_players",TASK_ID,_,_,"b") } public new_round() {     if(!task_exists(TASK_ID))             set_task(0.5,"check_players",TASK_ID,_,_,"b")     return PLUGIN_CONTINUE } public players_num(mode) {     new players[32],num     if(mode)         get_players(players,num,"a")     else if(!mode)         get_players(players,num)     return num; } public check_players() {     if(players_num(1) < MIN_PPL)     {         if(task_exists(TASK_ID))             remove_task(TASK_ID)         set_god()     }     for(new i=0;i<=players_num(1);i++)     {         set_user_hitzones(i,0,255)     }     return PLUGIN_HANDLED } public set_god() {     client_print(0,3,"--- %d or less players are alive. You can now kill. ---",MIN_PPL)     for(new i=0;i<players_num(1);i++)     {         set_user_hitzones(i,0,255)     }     return PLUGIN_HANDLED }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 06-21-2005 , 09:11  
Reply With Quote #5

I talked with him 1 hour ago, and he havnt said anything about the fall damage yet.

And he havnt told me that you could take over?

Cant you just let me finish my thing now?

I've allready made him another plugin too...

And what do I have as index on the set_user_godmode?
XunTric is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 06-21-2005 , 10:15  
Reply With Quote #6

He told me that he didn't want godmode ( makes sense because it's a surf server ).
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
mobytoss
Senior Member
Join Date: Jun 2004
Location: On my TS server
Old 06-21-2005 , 11:02  
Reply With Quote #7

Meh, I was just thinking, if you arent gonna fight on a surf map, might aswell let people surf as long as they like insteada killing them off, and letting them watch the others surf for hours. Never mind
__________________
"As we know, There are known knowns. There are things we know we know. We also know There are known unknowns. That is to say We know there are some things We do not know. But there are also unknown unknowns, The ones we don't know We don't know."
mobytoss is offline
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 06-21-2005 , 11:13  
Reply With Quote #8

Quote:
Originally Posted by v3x
He told me that he didn't want godmode ( makes sense because it's a surf server ).
Ok, but still, what do I have as index?
Ill change it later if he tells me that he wants something else.
XunTric is offline
mobytoss
Senior Member
Join Date: Jun 2004
Location: On my TS server
Old 06-21-2005 , 14:00  
Reply With Quote #9

The index is the number of the player you want to set god on
__________________
"As we know, There are known knowns. There are things we know we know. We also know There are known unknowns. That is to say We know there are some things We do not know. But there are also unknown unknowns, The ones we don't know We don't know."
mobytoss is offline
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 06-21-2005 , 18:29  
Reply With Quote #10

0 means all, right?
I tested with 0, and that didnt work.

So what do i put there? 4< ?
XunTric is offline
Reply



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 00:14.


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