AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   two different cvar values for two different players (https://forums.alliedmods.net/showthread.php?t=313103)

TheBladerX 12-28-2018 12:33

two different cvar values for two different players
 
Hello...
I have default cvar of value 4

Code:

farba = register_cvar("farbahud", "4")
And I would like to make following:
One player would have
Code:

set_pcvar_num( farba , 3 );
and the second
Code:

set_pcvar_num( farba , 2 );
simultaneously for example.

That means I need to make those cvars individual to all players, it would not be just server cvar, but every player will have his own individual value of cvar. Thanks

klippy 12-28-2018 12:39

Re: two different cvar values for two different players
 
It's not possible with cvars. You'll have to re-think what you are doing.

Bugsy 12-28-2018 12:39

Re: two different cvar values for two different players
 
Just use an array in your plugin, why do you need it to be a cvar?

TheBladerX 12-28-2018 14:12

Re: two different cvar values for two different players
 
Okay, I have no experience with that. Could you help me a little bit?

Bugsy 12-28-2018 15:05

Re: two different cvar values for two different players
 
Every player is assigned an id (the slot on the server that they are placed in upon connection). You can use this throughout your plugin to identify that player.

Here's a very basic example. I recommend reading some tutorials and reviewing existing plugins to learn how to script. You are going to have many questions and this forum is very active so any question you have has likely been asked dozens of times.
PHP Code:

#include <amxmodx>

//MAX_PLAYERS value is 32 which is the max slots supported on a server. The array needs to be sized + 1
//to allow the id to be passed for slot 32 since arrays are indexed 0 to size-1.
new g_iPlayerValMAX_PLAYERS ];

public 
plugin_init()
{
    
register_clcmd"say /number" "ShowRandom" );
}

public 
client_authorizedid 
{
    
//Player connected, assign random value to him.
    
g_iPlayerValid ] = random100 );
}

public 
client_disconnectid 
{
    
//Player disconnected, set his value to 0.
    
g_iPlayerValid ] = 0;
}

public 
ShowRandomid )
{
    
client_printid print_chat "Your number is %d" g_iPlayerValid ] );




All times are GMT -4. The time now is 07:33.

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