AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   If a player join late (https://forums.alliedmods.net/showthread.php?t=63402)

Claw 11-20-2007 08:30

If a player join late
 
So im using this plugin which gives everyone a chance to get a random item at start of each round, but if it happens that a player joins about 5 seconds after the round starts, he doesnt get the use of this plugin.

How can i make it execute the same random chance on players if they join the game a few seconds after round starts?

Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define TIME_TO_WAIT 2.0

public plugin_init()
{
        register_logevent("round_start", 2, "1=Round_Start")
}

public main_func()
{
        new players[32], num
        get_players(players, num)
        new player
        for(new i = 0; i < num; i++)
        {
                player = players[i]
                new health = get_user_health(player);

                if(random_num(0, 100) <= 1)
                {                       
                        give_item(player, "weapon_scout")
                       
                        cs_set_user_bpammo(player, CSW_SCOUT, 0)
                        client_print(player, print_chat, "[Lottery] you just won a scout with 1 bullet (1 percent chance)")
                }
               
                if(random_num(0, 100) <= 2)
                {
                        give_item(player, "weapon_deagle")       
                       
                        cs_set_user_bpammo(player, CSW_DEAGLE, 0)
                        client_print(player, print_chat, "[Lottery] you just won a deagle with 1 bullet (2 percent chance)")
                }
               
                if(random_num(0, 100) <= 15)
                {
                        give_item(player, "weapon_hegrenade")
                        client_print(player, print_chat, "[Lottery] you just won a HE-grenade (15 percent chance)")
                }
               
                if(random_num(0, 100) <= 10)
                if (cs_get_user_team(player) == CS_TEAM_T)
                {
                          give_item(player, "weapon_shield")
                          client_print(player, print_chat, "[Lottery] you just won a shield (10 percent chance)")
                }
               
                if(random_num(0, 100) <= 1)
                {
                        health += 100;
                        set_user_health(player,health); 
                        client_print(player, print_chat, "[Lottery] you just won 100 extra health (1 percent chance)")
                }

                if(random_num(0, 100) <= 5)
                {
                        health += 50;
                        set_user_health(player,health); 
                        client_print(player, print_chat, "[Lottery] you just won 50 extra health (5 percent chance)")
                }

                if(random_num(0, 100) <= 10)
                {
                        health += 25;
                        set_user_health(player,health); 
                        client_print(player, print_chat, "[Lottery] you just won 25 extra health (10 percent chance)")
                }

                if(random_num(0, 100) <= 25)
                {
                        cs_set_user_armor(player, 100, CS_ARMOR_VESTHELM)       
                        client_print(player, print_chat, "[Lottery] you just won a kevlar and helmet (25 percent chance)")
                }
}
}

public round_start()
{
        set_task(TIME_TO_WAIT, "main_func")
}


purple_pixie 11-20-2007 09:09

Re: If a player join late
 
Couldn't you just up TIME_TO_WAIT to 5 seconds.

Then the players get their item 5 seconds after round starts.

So anyone who joined before then would get one.

Claw 11-20-2007 13:03

Re: If a player join late
 
Well but if the player joins later then 5 seconds? ;)

purple_pixie 11-21-2007 04:34

Re: If a player join late
 
Nothing.

What is happening, is that 5 seconds (2 atm) after the round starts, it scans every connected player and gives the items on a chance.

So if they weren't connected then, they get no item.
It's not setting a timer to 5 seconds after they spawn, and then running it just for that player.


p.s. - you do know a player could win every single item, right?

Claw 11-21-2007 13:34

Re: If a player join late
 
Quote:

Originally Posted by purple_pixie (Post 555242)
Nothing.

What is happening, is that 5 seconds (2 atm) after the round starts, it scans every connected player and gives the items on a chance.

So if they weren't connected then, they get no item.
It's not setting a timer to 5 seconds after they spawn, and then running it just for that player.


p.s. - you do know a player could win every single item, right?

Well yeah i know what it does and im using it now, it's all good and i know that a player can win every thing if he is pretty darn lucky. Its the lottery! :P

But i dont want longer delay on the item chance, what i really want is that it executes the plugin on the player whenever he starts the round/joins and gets to play. And yeah btw, i have no clue on how to script/code so i dont know if it really is possible :P

purple_pixie 11-22-2007 05:15

Re: If a player join late
 
Oh right, now I'm with you.

For some reason I thought you just wanted the time upped slightly, but really you want everyone to get the plugin.

In *that* case ... gimme a little time and I'll slightly rewrite it.

EDIT: Try this one for size:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #include <fakemeta> #define TIME_TO_WAIT 2.0 #define TASK_ID 2796 public plugin_init() {     register_forward(FM_Spawn,"on_spawn",1) } public main_func(const taskid) {     new player = taskid - TASK_ID ;     if ( is_user_alive(player) )     {         new health = get_user_health(player);         if(random_num(0, 100) <= 1)         {                       give_item(player, "weapon_scout")                         cs_set_user_bpammo(player, CSW_SCOUT, 0)             client_print(player, print_chat, "[Lottery] you just won a scout with 1 bullet (1 percent chance)")         }                 if(random_num(0, 100) <= 2)         {             give_item(player, "weapon_deagle")                          cs_set_user_bpammo(player, CSW_DEAGLE, 0)             client_print(player, print_chat, "[Lottery] you just won a deagle with 1 bullet (2 percent chance)")         }                 if(random_num(0, 100) <= 15)         {             give_item(player, "weapon_hegrenade")             client_print(player, print_chat, "[Lottery] you just won a HE-grenade (15 percent chance)")         }                 if(random_num(0, 100) <= 10)         if (cs_get_user_team(player) == CS_TEAM_T)         {             give_item(player, "weapon_shield")             client_print(player, print_chat, "[Lottery] you just won a shield (10 percent chance)")         }                 if(random_num(0, 100) <= 1)         {             health += 100;             set_user_health(player,health);               client_print(player, print_chat, "[Lottery] you just won 100 extra health (1 percent chance)")         }         if(random_num(0, 100) <= 5)         {             health += 50;             set_user_health(player,health);               client_print(player, print_chat, "[Lottery] you just won 50 extra health (5 percent chance)")         }         if(random_num(0, 100) <= 10)         {             health += 25;             set_user_health(player,health);               client_print(player, print_chat, "[Lottery] you just won 25 extra health (10 percent chance)")         }         if(random_num(0, 100) <= 25)         {             cs_set_user_armor(player, 100, CS_ARMOR_VESTHELM)               client_print(player, print_chat, "[Lottery] you just won a kevlar and helmet (25 percent chance)")         }     } } public on_spawn(id) {     set_task(TIME_TO_WAIT, "main_func",TASK_ID+id) }

Claw 11-22-2007 08:41

Re: If a player join late
 
Ehm is it only me, or is it not possible to copy it? When i copy it from here it get's like this:
Code:

#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #include <fakemeta> #define TIME_TO_WAIT 2.0 #define TASK_ID 2796 public plugin_init() {    register_forward(FM_Spawn,"on_spawn",1) } public main_func(const taskid) {    new player = taskid - TASK_ID ;    if ( is_user_alive(player) )    {        new health = get_user_health(player);        if(random_num(0, 100) <= 1)        {                      give_item(player, "weapon_scout")                        cs_set_user_bpammo(player, CSW_SCOUT, 0)            client_print(player, print_chat, "[Lottery] you just won a scout with 1 bullet (1 percent chance)")        }                if(random_num(0, 100) <= 2)        {            give_item(player, "weapon_deagle")                          cs_set_user_bpammo(player, CSW_DEAGLE, 0)            client_print(player, print_chat, "[Lottery] you just won a deagle with 1 bullet (2 percent chance)")        }                if(random_num(0, 100) <= 15)        {            give_item(player, "weapon_hegrenade")            client_print(player, print_chat, "[Lottery] you just won a HE-grenade (15 percent chance)")        }                if(random_num(0, 100) <= 10)        if (cs_get_user_team(player) == CS_TEAM_T)        {        give_item(player, "weapon_shield")      client_print(player, print_chat, "[Lottery] you just won a shield (10 percent chance)")        }                if(random_num(0, 100) <= 1)        {            health += 100;            set_user_health(player,health);              client_print(player, print_chat, "[Lottery] you just won 100 extra health (1 percent chance)")        }        if(random_num(0, 100) <= 5)        {            health += 50;            set_user_health(player,health);              client_print(player, print_chat, "[Lottery] you just won 50 extra health (5 percent chance)")        }        if(random_num(0, 100) <= 10)        {            health += 25;            set_user_health(player,health);              client_print(player, print_chat, "[Lottery] you just won 25 extra health (10 percent chance)")        }        if(random_num(0, 100) <= 25)        {            cs_set_user_armor(player, 100, CS_ARMOR_VESTHELM)                client_print(player, print_chat, "[Lottery] you just won a kevlar and helmet (25 percent chance)")        }    } } public on_spawn(id) {    set_task(TIME_TO_WAIT, "main_func",TASK_ID+id) }
And then it's not possible to compile, could you maybe compile it for me? ^^

[ --<-@ ] Black Rose 11-22-2007 10:28

Re: If a player join late
 
register_plugin()?
It's you.

purple_pixie 11-22-2007 10:29

Re: If a player join late
 
1 Attachment(s)
But just for kicks

Claw 11-22-2007 10:53

Re: If a player join late
 
Hmm doesn't seem to work, either im just damn unlucky not winning anything on 15rounds or it's not working :P


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

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