Raised This Month: $ Target: $400
 0% 

[Question]Use command once per round?(more in post) :D


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nML
New Member
Join Date: Feb 2012
Old 02-12-2012 , 11:35   [Question]Use command once per round?(more in post) :D
Reply With Quote #1

Hi guys!
I recently started scripting, and i have LOADS of questions (All hail the Search Bar), but this one i couldn't find :
Lets say umm.... that there is a Vitamins plugin! When a user types /vitamins that....he gains 50 HP! Now here's the question :
How can i make the vitamins(for example) plugin, that the user can only use it once per round(if he tries to use it twice that a message apperars in his chat), and that the vitamins last only 1 round, so if he wants them the next round, he'll have t type /vitamins again!!?!?!?!?
For scripters out there this might seem stupid, but i'm new!!!
__________________
Quote:
You can do anything, but not everything..
-David Allen
nML is offline
BeeFighter
Member
Join Date: Feb 2012
Old 02-12-2012 , 12:07   Re: [Question]Use command once per round?(more in post) :D
Reply With Quote #2

PHP Code:
/* Plugin generated by AMXX-Studio */

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

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

new bool:AlreadyUsed[33]


public 
plugin_init() 
{
    
register_plugin(PLUGINVERSION"Pancakez")
    
    
register_logevent("RoundStart"2"2=Round_Start")

    
register_clcmd("say /vitamins""GiveVitamins")
}

public 
RoundStart(id)
{
    
AlreadyUsed[id] = false
}

public 
GiveVitamins(id)
{
    if(
AlreadyUsed[id] == true)
    {
        
client_print(idprint_chat"You already used Vitamins this round!")
    }
    else 
    {
        
set_user_health(idget_user_health(id) + 50)
        
AlreadyUsed[id] = true
    
}

Haven't tested it, should work like this.
BeeFighter is offline
nML
New Member
Join Date: Feb 2012
Old 02-12-2012 , 12:23   Re: [Question]Use command once per round?(more in post) :D
Reply With Quote #3

THANKS BRO !!
__________________
Quote:
You can do anything, but not everything..
-David Allen
nML is offline
Old 02-12-2012, 12:25
nML
This message has been deleted by nML.
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 02-12-2012 , 14:17   Re: [Question]Use command once per round?(more in post) :D
Reply With Quote #4

RoundStart event doesn't pass any index.

hook Ham_Spawn, or use arrayset in RoundStart event instead.
__________________
You can do anything you set your mind to, man.


Last edited by Devil259; 02-12-2012 at 14:17.
Devil259 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2012 , 18:52   Re: [Question]Use command once per round?(more in post) :D
Reply With Quote #5

Quote:
Originally Posted by Devil259 View Post
hook Ham_Spawn, or use arrayset in RoundStart event instead.
Spawn is not the same as a round starting, and therefore, should not be used as such.
__________________
fysiks is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 02-13-2012 , 01:33   Re: [Question]Use command once per round?(more in post) :D
Reply With Quote #6

So, use arrayset ?
__________________
You can do anything you set your mind to, man.

Devil259 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-13-2012 , 13:58   Re: [Question]Use command once per round?(more in post) :D
Reply With Quote #7

Quote:
Originally Posted by Devil259 View Post
So, use arrayset ?
That wasn't related to my comment but yes, it can be used. The code posted by BeeFighter is incorrect because there is no "id" passed with the round start event. This is where arrayset() should be used.
__________________
fysiks is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 02-13-2012 , 15:02   Re: [Question]Use command once per round?(more in post) :D
Reply With Quote #8

Code:
#include <amxmodx> #include <fun> new bool:bAlreadyUsed[ 33 ] public plugin_init() {     register_event( "HLTV" , "evNewRound" , "a" , "1=0" , "2=0" );     register_clcmd( "say /vitamins" , "GiveVitamins" ); } public evNewRound( )     arrayset( bAlreadyUsed , false , sizeof( bAlreadyUsed ) ); public GiveVitamins( id ) {     if( is_user_alive( id ) )     {         if( bAlreadyUsed[ id ] )         {             client_print( id , print_chat , "You already used Vitamins this round!" );         }             else         {             set_user_health( id , get_user_health( id ) + 50 )             bAlreadyUsed[ id ] = true         }     } }

That should be enough.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
BeeFighter
Member
Join Date: Feb 2012
Old 02-13-2012 , 15:09   Re: [Question]Use command once per round?(more in post) :D
Reply With Quote #9

Quote:
Originally Posted by Devil259 View Post
Code:
#include <amxmodx> #include <fun> new bool:bAlreadyUsed[ 33 ] public plugin_init() {     register_event( "HLTV" , "evNewRound" , "a" , "1=0" , "2=0" );     register_clcmd( "say /vitamins" , "GiveVitamins" ); } public evNewRound( )     arrayset( bAlreadyUsed , false , sizeof( bAlreadyUsed ) ); public GiveVitamins( id ) {     if( is_user_alive( id ) )     {         if( bAlreadyUsed[ id ] )         {             client_print( id , print_chat , "You already used Vitamins this round!" );         }             else         {             set_user_health( id , get_user_health( id ) + 50 )             bAlreadyUsed[ id ] = true         }     } }

That should be enough.
Thanks for the correction.
BeeFighter 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 05:51.


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