AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spawn counter for each player (https://forums.alliedmods.net/showthread.php?t=216664)

alonelive 05-24-2013 02:37

Spawn counter for each player
 
Hello!
How can i count the spawns of player?


PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new spawn_count

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""PlayerPostSpawn"1);
}

public 
PlayerPostSpawn(id)
{
    
spawn_count++ //This is a TOTAL counter.
    //I need a counter for each player (individual spawn counter).. spawn_count(id)++ ???
    
    
    //for example
    
if(spawn_count/*(id)*/ 5)
    {
        
cs_set_user_bpammo(idCSW_HEGRENADE2)
    }
    else
        
cs_set_user_bpammo(idCSW_HEGRENADE1)
    
//for example



Blizzard_87 05-24-2013 03:12

Re: Spawn counter for each player
 
Quote:

Originally Posted by alonelive (Post 1957361)
Hello!
How can i count the spawns of player?


PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new spawn_count

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""PlayerPostSpawn"1);
}

public 
PlayerPostSpawn(id)
{
    
spawn_count++ //This is a TOTAL counter.
    //I need a counter for each player (individual spawn counter).. spawn_count(id)++ ???
    
    
    //for example
    
if(spawn_count/*(id)*/ 5)
    {
        
cs_set_user_bpammo(idCSW_HEGRENADE2)
    }
    else
        
cs_set_user_bpammo(idCSW_HEGRENADE1)
    
//for example



change to this

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new spawn_count33 ];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""PlayerPostSpawn"1);
}

public 
PlayerPostSpawn(id)
{
    
spawn_countid ]++ 
    
    
    
//for example
    
if(spawn_countid ] > 5)
    {
        
cs_set_user_bpammo(idCSW_HEGRENADE2)
    }
    else
        
cs_set_user_bpammo(idCSW_HEGRENADE1)




alonelive 05-24-2013 03:22

Re: Spawn counter for each player
 
Blizzard_87, Thank you!

alonelive 05-24-2013 03:49

Re: Spawn counter for each player
 
One question...
new spawn_count[ 33 ]; Why 33?

EpicMonkey 05-24-2013 04:35

Re: Spawn counter for each player
 
Read this: https://forums.alliedmods.net/showthread.php?t=94381

guipatinador 05-24-2013 05:49

Re: Spawn counter for each player
 
- Make sure that user is alive.
- Change spawn count to zero in those events - Game_Commencing and Game_will_restart_in (just a suggestion)

alonelive 05-24-2013 08:15

Re: Spawn counter for each player
 
Thank you all!

>> - Change spawn count to zero in those events - Game_Commencing and Game_will_restart_in (just a suggestion)
No.. This function will be used in other code (vip features for exolent's vip plugin).
there are some menus for each round from map's beginning: round 1 - only pistol weapon menu, round 2 - pistol, famas, mp5 and previous, etc.; round 3 - ak47, m4a1, and previous, round 4 and all next rounds - full weapon menu (including awp).
And for that I needed this calculations with spawn.

guipatinador 05-24-2013 08:51

Re: Spawn counter for each player
 
Quote:

Originally Posted by alonelive (Post 1957491)
Thank you all!

No.. This function will be used in other code (vip features for exolent's vip plugin).
there are some menus for each round from map's beginning: round 1 - only pistol weapon menu, round 2 - pistol, famas, mp5 and previous, etc.; round 3 - ak47, m4a1, and previous, round 4 and all next rounds - full weapon menu (including awp).
And for that I needed this calculations with spawn.

You don't understand what I said.

Imagine the following situation,
- The server is empty
- Player A join to T or CT (spawn count = 1)
- Player B join to the opposite team and make the first spawn (spawn count = 1 for this player)
- After this point, the game is restarted. After the game restart both players respawn (obviously) and spawn count for both players is now 2
- In the same round, after a few seconds, player C joins T or CT and is spawned (spawn count = 1)

What is the problem here?
- This is officialy the first round but players A and B already have 2 spawn counts, and the player C only 1 spawn count.
- Players A and B will get the menu with pistols, famas, mp5, etc... and player C only get the menu with pistols.

The problem is solved if you reset the spawn count of the players in game restart or game commecing.

If you don't care, I already don't care. Do what you want but don't ask why some players get weapons instead of pistols in the first round.

alonelive 05-24-2013 12:05

Re: Spawn counter for each player
 
I have this code:

PHP Code:

    register_event("TextMsg""restart_rounds""a""2=#Game_will_restart_in");
    
register_event("TextMsg""restart_rounds""a""2&#Game_C")
    
register_event("SendAudio""restart_rounds""a""2=%!MRAD_rounddraw"

PHP Code:

public restart_rounds()
{
        
rounds_elapsed 0
        g_vip_spawn 
0


Thank you for your suggestion!:bacon!:

EpicMonkey 05-25-2013 05:19

Re: Spawn counter for each player
 
Quote:

Originally Posted by guipatinador (Post 1957427)
- Make sure that user is alive.
- Change spawn count to zero in those events - Game_Commencing and Game_will_restart_in (just a suggestion)

Those events are gonna trigger the Round_Start event right?


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

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