Raised This Month: $ Target: $400
 0% 

two different cvar values for two different players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 12-28-2018 , 12:33   two different cvar values for two different players
Reply With Quote #1

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

Last edited by TheBladerX; 12-28-2018 at 12:34.
TheBladerX is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-28-2018 , 12:39   Re: two different cvar values for two different players
Reply With Quote #2

It's not possible with cvars. You'll have to re-think what you are doing.
__________________
klippy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-28-2018 , 12:39   Re: two different cvar values for two different players
Reply With Quote #3

Just use an array in your plugin, why do you need it to be a cvar?
__________________
Bugsy is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 12-28-2018 , 14:12   Re: two different cvar values for two different players
Reply With Quote #4

Okay, I have no experience with that. Could you help me a little bit?
TheBladerX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-28-2018 , 15:05   Re: two different cvar values for two different players
Reply With Quote #5

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 ] );

__________________

Last edited by Bugsy; 12-28-2018 at 15:14.
Bugsy 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 16:24.


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