AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Cvar setting problem (https://forums.alliedmods.net/showthread.php?t=159372)

Melisko 06-16-2011 10:00

Cvar setting problem
 
1 Attachment(s)
Hi , I need help with setting some cvars . Here is the part of a plugin:

public svm_item_on( iPlayer, iItemIndex, bool:iPluginON) {

Quote:

if( g_iItemIndex == iItemIndex ) {

if(iPluginON) { get_cvar_string
client_cmd(player_id,";alias bhop_auto")

client_print( iPlayer , print_chat, "Bunny Hop je Zapnuty!")


}
else { client_cmd(player_id,"bhop_auto 0")
client_cmd(player_id,";alias bhop_auto")

client_print( iPlayer , print_chat, "Bunny Hop je Vypnuty!")

}
}

//return if needed here
}
I want to set the cvar bhop_auto like this : if(iPluginON) bhop_auto 1

and this : else bhop_auto 0

Thanks 4 help :)


////(My script can be find at the bottom of the plugin)////

Devil259 06-16-2011 10:36

Re: Cvar setting problem
 
Try to use set_pcvar_num( ).

Code:
if( iPluginON ) {      set_pcvar_num( g_pcvarAutoBhop , 1 ) }

Melisko 06-16-2011 11:06

Re: Cvar setting problem
 
Quote:

Originally Posted by Devil259 (Post 1489374)
Try to use set_pcvar_num( ).

Code:
if( iPluginON ) { set_pcvar_num( g_pcvarAutoBhop , 1 ) }

Thanks , this help me alot , but is it possible to set the cvar only for 1 player??? , Im making a VIP plugin , so the vips can choose if they want bunny hop or not , normal players can have bhop too , but they cant disable it (thats my plan). When I used this , it changed the server cvar and it disabled bhop to all players on the server....

Devil259 06-16-2011 11:09

Re: Cvar setting problem
 
Quote:

amx_autobhop <nick|#userid> <0|1>
Give autojump ability to a player (when bhop_auto is 0)
from ConnorMcLeod's post (see Bunny Hop Abilities v0.5.2 plugin).

So, use server_cmd( ).

Melisko 06-16-2011 11:13

Re: Cvar setting problem
 
Quote:

Originally Posted by Devil259 (Post 1489402)
from ConnorMcLeod's post (see Bunny Hop Abilities v0.5.2 plugin).

So, use server_cmd( ).

I think I wrote my last post wrong... I mean , enable/disable cvar bhop_auto only for player , that choose it in vip menu..... Im not rly good at scripting.....

Is it possbile that each player can have enable different cvar???

Devil259 06-16-2011 11:20

Re: Cvar setting problem
 
Code:
if( iPluginON ) {      server_cmd( "amx_autobhop %d 1" , get_user_userid( id ) ) }

Try this.

Melisko 06-16-2011 16:06

Re: Cvar setting problem
 
Quote:

Originally Posted by Devil259 (Post 1489409)
Code:
if( iPluginON ) { server_cmd( "amx_autobhop %d 1" , get_user_userid( id ) ) }


Try this.

Sorry but I cant compile it.... I have got errors . Like I said , Im not really good at scripting...

Devil259 06-16-2011 16:59

Re: Cvar setting problem
 
Show whole code.

Melisko 06-16-2011 17:13

Re: Cvar setting problem
 
1 Attachment(s)
Quote:

Originally Posted by Devil259 (Post 1489589)
Show whole code.

Ok , the svmplugintest.sma is a "tutorial" how to make that vip... actually Im using this plugin : http://forums.alliedmods.net/showthread.php?t=147276 , it is very hard to code it for me , I have got so many errors...

And now the Bunny Hop plugin : (Im gonna post the original) : http://forums.alliedmods.net/showthread.php?p=610329

And now I will tell you how I want to use this plugin : The Bunny Hop will be enabled for all players . But , when VIP(and admins) player write /vipmenu to the chat , he can disable the Bunny-Hopping in the menu (only for him)..... Thats all.....

VIPmenu is coded in vip plugin

And I have got error messages like this : 41.: loose identation , invalid expression assumed zero. etc...

Devil259 06-16-2011 17:40

Re: Cvar setting problem
 
You have to add a case in the menu which enable/disable the bunny hop to VIP's and, in the menu handler, add thing like :

Code:
case X: // I don't know the number of case there are {      if( bHaveBhop[ id ] )      {           server_cmd( id , "amx_autobhop %d 0" , get_user_userid( id ) )           client_print( id , print_chat , "BunnyHop disabled" )           bHaveBhop[ id ] = false      }      else      {           server_cmd( id , "amx_autobhop %d 1" , get_user_userid( id ) )           client_print( id , print_chat , "BunnyHop enabled" )           bHaveBhop[ id ] = true      } }

Don't forget to add a booléen.


All times are GMT -4. The time now is 23:28.

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