Raised This Month: $ Target: $400
 0% 

[Help] Fuction only usable once


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 12-25-2014 , 01:11   [Help] Fuction only usable once
Reply With Quote #1

How do i make a fuction only usable once?
Syturi0 is offline
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 12-25-2014 , 03:37   Re: [Help] Fuction only usable once
Reply With Quote #2

use boolean and when function runs first check that boolean should return false to run that function and when function execute then make boolean as true.
__________________
All my work is here
xxxperts is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 12-25-2014 , 04:08   Re: [Help] Fuction only usable once
Reply With Quote #3

Quote:
Originally Posted by xxxperts View Post
use boolean and when function runs first check that boolean should return false to run that function and when function execute then make boolean as true.
I want to make it only usable 1 time, for ever, even if i restart server ect.
Syturi0 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-25-2014 , 04:49   Re: [Help] Fuction only usable once
Reply With Quote #4

Then, you need to save the boolean using nVault.
zmd94 is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 12-25-2014 , 05:10   Re: [Help] Fuction only usable once
Reply With Quote #5

PHP Code:
new bool:AlreadyUsed[33]

if( 
AlreadyUsedid ] )
{
 
client_print(idprint_chat"This was already used!)
}

if(equal(say, Stuff))
{
 //blabla
        
 AlreadyUsed[ id ] = true

Is it right?
And how i implement nVault in this?

Last edited by Syturi0; 12-25-2014 at 05:11.
Syturi0 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-25-2014 , 05:15   Re: [Help] Fuction only usable once
Reply With Quote #6

Just visit this: https://forums.alliedmods.net/showthread.php?p=2229756
zmd94 is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 12-25-2014 , 05:26   Re: [Help] Fuction only usable once
Reply With Quote #7

I forgot to say, once the function is used, no outher player can use it again.
Syturi0 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-25-2014 , 05:31   Re: [Help] Fuction only usable once
Reply With Quote #8

Just use the code from here: https://forums.alliedmods.net/showpo...7&postcount=13
zmd94 is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 12-25-2014 , 06:18   Re: [Help] Fuction only usable once
Reply With Quote #9

PHP Code:

#define MAX_PLAYERS    32 

enum ( <<=)

    
abc// 1 << 0 or 1   
    
dfg// 1 << 1 or 1 << 1 (as value is calculated by enum)    
}

new 
g_OptionsMAX_PLAYERS ];
new 
g_VaultID

#define HasOption(%1,%2)    g_Options[%1]&%2 
#define AddOption(%1,%2)    g_Options[%1]|=%2 
#define RemoveOption(%1,%2)    g_Options[%1]&=~%2 

public plugin_init()
{    
register_plugin(PLUGINVERSIONAUTHOR)
g_VaultID nvault_open"testvault" ); 
}

public 
client_putinserver(id)
{
    
LoadFlags(id)
}

public 
client_disconnect(id)
{
    
SaveFlags(id)
}

public 
a1id 

    if ( 
HasOptionid abc ) ) 
        
a11id ); 


public 
a2id 

    if ( 
HasOptionid dfg ) ) 
        
a22id ); 


public 
PlayerWasBadid 

    
RemoveOptionid abc ); 
    
RemoveOptionid dfg ); 


public 
SaveFlagsid 

    new 
name[35]
    
get_user_name(idname34)

    new 
szData15 ]; 
    
num_to_strg_Optionsid ] , szData charsmaxszData ) ); 
    
nvault_setg_VaultID name szData ); 


public 
LoadFlagsid 

    new 
name[35]
    
get_user_name(idname34)

    
g_Optionsid ] = nvault_getg_VaultID name);   


public 
a11(id){} 
public 
a22(id){} 
Didnt work.
Syturi0 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-25-2014 , 08:39   Re: [Help] Fuction only usable once
Reply With Quote #10

Sorry, after tried a few methods, I still cannot find the correct way to do as your request.

However, if you want to restrict the item for one map, I can help you.
zmd94 is offline
Reply


Thread Tools
Display Modes

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 15:32.


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