AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Fuction only usable once (https://forums.alliedmods.net/showthread.php?t=253608)

Syturi0 12-25-2014 01:11

[Help] Fuction only usable once
 
How do i make a fuction only usable once?

xxxperts 12-25-2014 03:37

Re: [Help] Fuction only usable once
 
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.

Syturi0 12-25-2014 04:08

Re: [Help] Fuction only usable once
 
Quote:

Originally Posted by xxxperts (Post 2239745)
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.

zmd94 12-25-2014 04:49

Re: [Help] Fuction only usable once
 
Then, you need to save the boolean using nVault.

Syturi0 12-25-2014 05:10

Re: [Help] Fuction only usable once
 
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?

zmd94 12-25-2014 05:15

Re: [Help] Fuction only usable once
 
Just visit this: https://forums.alliedmods.net/showthread.php?p=2229756

Syturi0 12-25-2014 05:26

Re: [Help] Fuction only usable once
 
I forgot to say, once the function is used, no outher player can use it again.

zmd94 12-25-2014 05:31

Re: [Help] Fuction only usable once
 
Just use the code from here: https://forums.alliedmods.net/showpo...7&postcount=13

Syturi0 12-25-2014 06:18

Re: [Help] Fuction only usable once
 
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.

zmd94 12-25-2014 08:39

Re: [Help] Fuction only usable once
 
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.


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

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