AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Every x rounds (https://forums.alliedmods.net/showthread.php?t=189589)

dasha 07-08-2012 19:01

Every x rounds
 
Can't find a tut about it, there's one about round events, but can't combine it with what I need..so I ask for help :oops:

I will leave a example so you can understand what I need :L

PHP Code:


new cvar_1cvar_2cvar_3

public plugin_init() {
    
    
register_clcmd("say cvar1""cmdCvar1")
    
register_clcmd("say cvar2""cmdCvar2")
    
register_clcmd("say cvar3""cmdCvar3")

    
cvar_1 register_cvar("cvar3""2")
    
cvar_2 register_cvar("cvar2""3")
    
cvar_3 register_cvar("cvar3""5")
}

public 
cmdCvar1(id) {
    
    
// round event ( cvar_1 is "2", so you can get awp every 2 rounds
    
    
give_item(id"weapon_awp")
    
}

public 
cmdCvar2(id) {
    
    
// round event ( cvar_2 is "3", so you can get scout every 3 rounds
    
    
give_item(id"weapon_scout"
}

public 
cmdCvar3(id) {
    
    
// round event ( cvar_3 is "5", so you can get famas every 5 rounds
    
    
give_item(id"weapon_famas"


That's all :P

Bugsy 07-08-2012 19:07

Re: Every x rounds
 
Use counter variables in combination with this.

dasha 07-09-2012 12:57

Re: Every x rounds
 
Would be better if you show an example.

Liverwiz 07-09-2012 13:39

Re: Every x rounds
 
Have a global round-counter i.e. new g_rndCnt
At the beginning of each round g_rndCnt++
Then to figure out if its the proper round do....
Code:

// globals
new g_rndCnt

// Event_Spawn- whatever you want to hook spawn to
g_rndCnt++

// cmdCvar functions
if(g_rndCnt % get_pcvar_num(cvar_2) == 0)
// Execution for weapon_scout

This will check if its the proper round. If you want more informatio on the % operator. Look up modulus. Its a VERY popular operation. Won't be hard to find stuff on it.


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

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