Raised This Month: $ Target: $400
 0% 

Spawn counter for each player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-24-2013 , 02:37   Spawn counter for each player
Reply With Quote #1

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

__________________
sorry my bad english...

Last edited by alonelive; 05-24-2013 at 02:46.
alonelive is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-24-2013 , 03:12   Re: Spawn counter for each player
Reply With Quote #2

Quote:
Originally Posted by alonelive View Post
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)


__________________
Blizzard_87 is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-24-2013 , 03:22   Re: Spawn counter for each player
Reply With Quote #3

Blizzard_87, Thank you!
__________________
sorry my bad english...
alonelive is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-24-2013 , 03:49   Re: Spawn counter for each player
Reply With Quote #4

One question...
new spawn_count[ 33 ]; Why 33?
__________________
sorry my bad english...
alonelive is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 05-24-2013 , 04:35   Re: Spawn counter for each player
Reply With Quote #5

Read this: https://forums.alliedmods.net/showthread.php?t=94381
EpicMonkey is offline
guipatinador
SourceMod Donner Party
Join Date: Oct 2009
Location: Poortugal
Old 05-24-2013 , 05:49   Re: Spawn counter for each player
Reply With Quote #6

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

Last edited by guipatinador; 05-24-2013 at 05:50.
guipatinador is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 05-25-2013 , 05:19   Re: Spawn counter for each player
Reply With Quote #7

Quote:
Originally Posted by guipatinador View Post
- 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?
EpicMonkey is offline
guipatinador
SourceMod Donner Party
Join Date: Oct 2009
Location: Poortugal
Old 05-25-2013 , 05:59   Re: Spawn counter for each player
Reply With Quote #8

Quote:
Originally Posted by EpicMonkey View Post
Those events are gonna trigger the Round_Start event right?
New round first (HLTV event) and then Round_Start after the end of the freezetime.
guipatinador is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-24-2013 , 08:15   Re: Spawn counter for each player
Reply With Quote #9

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.
__________________
sorry my bad english...

Last edited by alonelive; 05-24-2013 at 08:19.
alonelive is offline
guipatinador
SourceMod Donner Party
Join Date: Oct 2009
Location: Poortugal
Old 05-24-2013 , 08:51   Re: Spawn counter for each player
Reply With Quote #10

Quote:
Originally Posted by alonelive View Post
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.

Last edited by guipatinador; 05-24-2013 at 08:53.
guipatinador 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 16:18.


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