• RunConsoleCommand
    19 replies, posted
Hi, I made this script but don't work, you know why ? thx for your help [CODE]if ply:Team() == TEAM_GIGN then RunConsoleCommand( nv_toggle_nightvision, 1 ) end[/CODE]
is nv_toggle_nightvision a variable? You seem to be treating it as one [editline]23rd August 2016[/editline] If it's meant to be a string it should be [CODE] RunConsoleCommand( "nv_toggle_nightvision", 1 ) [/CODE] Still, the way you're enabling nightvision seems a bit exploitable since anyone could run that command... unless that's what you want
I think using RunConsoleCommand like that would run the console command through the server, where it seems like you want to run it on the player. I think using ply:ConCommand("nv_toggle_nightvision 1") would do it.
from this addon [url]http://steamcommunity.com/sharedfiles/filedetails/?id=138163375[/url] it' is no ?[QUOTE=ST3BL;50933350]Hi, I made this script but don't work, you know why ? thx for your help [CODE]if ply:Team() == TEAM_GIGN then RunConsoleCommand( nv_toggle_nightvision, 1 ) end[/CODE][/QUOTE] [editline]23rd August 2016[/editline] I want for player spawn TEAM_GIGN (retrict for this steam) [QUOTE=sweetfoo;50933370]I think using RunConsoleCommand like that would run the console command through the server, where it seems like you want to run it on the player. I think using ply:ConCommand("nv_toggle_nightvision 1") would do it.[/QUOTE]
[QUOTE=ST3BL;50933373]I want for player spawn TEAM_GIGN[/QUOTE] [CODE] hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) if ply:Team() == TEAM_GIGN then ply:ConCommand( "nv_toggle_nightvision 1" ) end end ) [/CODE]
thx work but when I change team is no disable[QUOTE=MPan1;50933391][CODE] hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) if ply:Team() == TEAM_GIGN then ply:ConCommand( "nv_toggle_nightvision 1" ) end end ) [/CODE][/QUOTE]
Because you never made it disable? Just use an else statement Also, as I said before, the way you're doing it makes it easy for ANYONE to enable or disable night vision no matter what team they're on
[QUOTE=ST3BL;50933400]thx work but when I change team is no disable[/QUOTE] [code]hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) if ply:Team() == TEAM_GIGN then ply:ConCommand( "nv_toggle_nightvision 1" ) else ply:ConCommand( "nv_toggle_nightvision 0" ) end end ) [/code] Should do it. You get what you pay for..
[QUOTE=sweetfoo;50933414][code]hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) if ply:Team() == TEAM_GIGN then ply:ConCommand( "nv_toggle_nightvision 1" ) else ply:ConCommand( "nv_toggle_nightvision 0" ) end end ) [/code] Should do it. You get what you pay for..[/QUOTE] [code]hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) ply:ConCommand( "nv_toggle_nightvision " .. ply:Team() == TEAM_GIGN and 1 or 0 ) end )[/code] Could also simplify it to this.
ok for restrict another team it's correct this ? [CODE]hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) if (client:IsUserGroup("admin") or client:IsUserGroup("superadmin"))) then return true if ply:Team() == TEAM_GIGN then ply:ConCommand( "nv_toggle_nightvision 1" ) else ply:ConCommand( "nv_toggle_nightvision 0" ) end end end )[/CODE][QUOTE=MPan1;50933412]Because you never made it disable? Just use an else statement Also, as I said before, the way you're doing it makes it easy for ANYONE to enable or disable night vision no matter what team they're on[/QUOTE] [editline]23rd August 2016[/editline] thx man ^^[QUOTE=xbeastguyx;50933419][code]hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) ply:ConCommand( "nv_toggle_nightvision " .. ply:Team() == TEAM_GIGN and 1 or 0 ) end )[/code] Could also simplify it to this.[/QUOTE]
[CODE] if (client:IsUserGroup("admin") or client:IsUserGroup("superadmin"))) then return true [/CODE] Firstly, you never specified client, secondly, returning true ends the whole script making nothing after it run, thirdly, you could simplify all that by using IsAdmin, and fourthly, 2 other people already posted working code [editline]23rd August 2016[/editline] If you want it to be admin only: [CODE] hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) ply:ConCommand( "nv_toggle_nightvision " .. ( ply:Team() == TEAM_GIGN and ply:IsAdmin() ) and '1' or '0' ) end ) [/CODE]
this don't work [CODE]hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) ply:ConCommand( "nv_toggle_nightvision " .. ply:Team() == TEAM_GIGN and 1 or 0 ) end )[/CODE] and this too [CODE]hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) ply:ConCommand( "nv_toggle_nightvision " .. ( ply:Team() == TEAM_GIGN and ply:IsAdmin() ) and '1' or '0' ) end )[/CODE] NightVision is no enable and disable [QUOTE=MPan1;50933440][CODE] if (client:IsUserGroup("admin") or client:IsUserGroup("superadmin"))) then return true [/CODE] Firstly, you never specified client, secondly, returning true ends the whole script making nothing after it run, thirdly, you could simplify all that by using IsAdmin, and fourthly, 2 other people already posted working code [editline]23rd August 2016[/editline] If you want it to be admin only: [CODE] hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) ply:ConCommand( "nv_toggle_nightvision " .. ( ply:Team() == TEAM_GIGN and ply:IsAdmin() ) and '1' or '0' ) end ) [/CODE][/QUOTE]
Then just [CODE] hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) if ply:Team() == TEAM_GIGN and ply:IsAdmin() then ply:ConCommand( "nv_toggle_nightvision" ) end end ) [/CODE] If it's togglable then that should work unless the player changes teams or it starts off enabled - if so then it's going to be painful and you'll probably have to decompile the night vision addon just to figure out what it uses to toggle itself
this code run but if you change team NightVision is not disable and I tested give my rank user but I can use concommand [QUOTE=MPan1;50933495]Then just [CODE] hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) if ply:Team() == TEAM_GIGN and ply:IsAdmin() then ply:ConCommand( "nv_toggle_nightvision" ) end end ) [/CODE] If it's togglable then that should work unless the player changes teams or it starts off enabled - if so then it's going to be painful and you'll probably have to decompile the night vision addon just to figure out what it uses to toggle itself[/QUOTE] then I tested this [CODE]hook.Add( 'PlayerSpawn', 'NightVision', function( ply ) if ply:Team() == TEAM_GIGN and ply:IsAdmin() then ply:ConCommand( "nv_toggle_nightvision 1" ) else oldteam == TEAM_GIGN and ply:IsAdmin() then ply:ConCommand( "nv_toggle_nightvision 0" ) end end )[/CODE] work but user can use too ConCommand nv_toggle_nightvision wtf what is happening I decompiled addon and I see this [CODE]local on = false concommand.Add("nv_toggle_nightvision", function(ply, cmd, args) LocalPlayer():EmitSound(toggle_sound) on = not on end)[/CODE]
[QUOTE=ST3BL;50935629]work but user can use too ConCommand nv_toggle_nightvision wtf what is happening [/QUOTE] [QUOTE=MPan1;50933364]Still, the way you're enabling nightvision seems a bit exploitable since anyone could run that command... unless that's what you want[/QUOTE] No shit
And ?[QUOTE=Coffeee;50935749]No shit[/QUOTE]
You mean this command is working for all players. Not matter the rank. [CODE] concommand.Add("nv_toggle_nightvision", function(ply, cmd, args) if LocalPlayer():IsAdmin() then LocalPlayer():EmitSound(toggle_sound) on = not on else end end) [/CODE] Also this command added in ClientSide. Interesting... Can you link me the addon. maybe I find what is your problem with the permission :)
[QUOTE=kem008;50936248]You mean this command is working for all players. Not matter the rank. [CODE] concommand.Add("nv_toggle_nightvision", function(ply, cmd, args) if LocalPlayer():IsAdmin() then LocalPlayer():EmitSound(toggle_sound) on = not on else end end) [/CODE] Also this command added in ClientSide. Interesting... Can you link me the addon. maybe I find what is your problem with the permission :)[/QUOTE] Clean up your code, man. Got a random else statement, and use LocalPlayer() despite the provided player argument. [CODE] concommand.Add( "nv_toggle_nightvision", function( ply ) if ply:IsAdnin() then ply:EmitSound( toggle_sound ) on = not on end end ) [/CODE]
This is block for all user ? Maybe my code workind now for restrict for my Team GIGN and admin[QUOTE=xbeastguyx;50938984]Clean up your code, man. Got a random else statement, and use LocalPlayer() despite the provided player argument. [CODE] concommand.Add( "nv_toggle_nightvision", function( ply ) if ply:IsAdnin() then ply:EmitSound( toggle_sound ) on = not on end end ) [/CODE][/QUOTE]
Do this on the client, and use [I]actual[/I] cvars and not some console command to set a local variable. This is some half assed system.
Sorry, you need to Log In to post a reply to this thread.