• Will This Work?
    29 replies, posted
Will this work so when someone types challenge in console a weapon is equiped according to their steamid [CODE] concommand.Add( "Challenge",function( ply ) if ply:SteamID() == "STEAM_0:00000" ply:Give("m9k_ares_shrike") ent:EmitSound("Path/To/Sound.wav", 500, 200) end ) [/CODE] and also how do i make it so they can type !challenge in chat
You can do a chat command with the PlayerSay hook. Also, Give() is a server-side player method, so you'll need to do some networking if this is client-side.
hmm. can you help me with it? because im on my bros account
No, it won't work. Bad syntax. You'd know if you would've tested. And ply != ent As for your second question, PlayerSay EDIT: ninja'd
ok thanks but i cant test it because my friend needs it sometime today and wont let me upload it non-finished [editline]5th August 2014[/editline] [CODE] if CLIENT then hook.Add( "PlayerSay", "Challenge", function() if ply:SteamID() == "STEAM_0:00000" ply:Give("m9k_ares_shrike") ent:EmitSound("Path/To/Sound.wav", 500, 200) end end [/CODE] what about that
[QUOTE=TheCodingBoss;45602431]ok thanks but i cant test it because my friend needs it sometime today and wont let me upload it non-finished [editline]5th August 2014[/editline] [CODE] if CLIENT then hook.Add( "PlayerSay", "Challenge", function() if ply:SteamID() == "STEAM_0:00000" ply:Give("m9k_ares_shrike") ent:EmitSound("Path/To/Sound.wav", 500, 200) end end [/CODE] what about that[/QUOTE] No.
No. You didn't listen to Humble at all. Change all cases of ent to ply, and add ply and text and parameters passed in your function. You'll also need to check if the text is "challenge", not to mention the PlayerSay hook is serverside, so it would never work in its current state.
Please look into basic lua syntax before trying to make something for your friends. You're missing a then
It won't work because your missing a 'then' and an 'end'. This isn't python. [lua] concommand.Add( "Challenge",function( ply ) if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) end end ) [/lua]
[CODE] if CLIENT then hook.Add( "PlayerSay", "challenge", function() if ply:SteamID() == "STEAM_0:00000" then ply:Give("m9k_ares_shrike") ent:EmitSound("Path/To/Sound.wav", 500, 200) end end [/CODE] [editline]5th August 2014[/editline] Never Mind That
[QUOTE=TheCodingBoss;45602462][CODE] if CLIENT then hook.Add( "PlayerSay", "challenge", function() if ply:SteamID() == "STEAM_0:00000" then ply:Give("m9k_ares_shrike") ent:EmitSound("Path/To/Sound.wav", 500, 200) end end [/CODE] [editline]5th August 2014[/editline] Never Mind That[/QUOTE] Take a few minutes to carefully read each of the replies you were given.
[CODE] concommand.Add( "Challenge",function( ply ) if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) end end ) [/CODE] Ok So That Should Work? [editline]5th August 2014[/editline] read them all, now my brother recommended this for multiple ids, is this right? [CODE] concommand.Add( "challenge",function( ply ) if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) else if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) end end end end ) [/CODE] [editline]5th August 2014[/editline] hang on the ends went bad [editline]5th August 2014[/editline] concommand.Add( "challenge",function( ply ) if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) else if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) end end end end )
[QUOTE=TheCodingBoss;45602480][editline]5th August 2014[/editline] read them all, now my brother recommended this for multiple ids, is this right? [CODE] concommand.Add( "challenge",function( ply ) if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) else if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) end end end end ) [/CODE] [editline]5th August 2014[/editline] hang on the ends went bad [editline]5th August 2014[/editline] concommand.Add( "challenge",function( ply ) if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) else if (ply:SteamID() == "STEAM_0:00000" ) then ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) end end end end )[/QUOTE] Nope. Remove the 2 last "end"s.
[QUOTE=TheCodingBoss;45602431]ok thanks but i cant test it because my friend needs it sometime today and wont let me upload it non-finished [editline]5th August 2014[/editline] [CODE] if CLIENT then hook.Add( "PlayerSay", "Challenge", function() if ply:SteamID() == "STEAM_0:00000" ply:Give("m9k_ares_shrike") ent:EmitSound("Path/To/Sound.wav", 500, 200) end end [/CODE] what about that[/QUOTE] The PlayerSay hook is ServerSide([URL="http://wiki.garrysmod.com/page/GM/PlayerSay"]PlayerSay[/URL]). Sintax is wrong, you forgot to put the vars of the function. Everything that players chat will give him a Ares Shrike(Is it wrong?) May use this [CODE] if SERVER then hook.Add( "PlayerSay", "Challenge", function(ply, text, team) if ply:SteamID() == "STEAM_0:00000" ply:Give("m9k_ares_shrike") ply:EmitSound("Path/To/Sound.wav", 500, 200) end end) end [/CODE]
[QUOTE=TrinityX;45602524]Nope. Remove the 2 last "end"s.[/QUOTE] Only one needs to be removed because he's using else if instead of elseif
so whats the chat command?
everything previously stated in the thread has been forgotten in TheCodingBoss' mind
Why is it that you always say you are on your brothers account, I haven't seen any of 'your brothers' coding boss skills. You chose a horrible name. Why did your brother even make an account and then never go on it.
[QUOTE=AnonTakesOver;45606412]Why is it that you always say you are on your brothers account, I haven't seen any of 'your brothers' coding boss skills. You chose a horrible name. Why did your brother even make an account and then never go on it.[/QUOTE] he probably killed him with his stupidity, sry that was mean --EDIT-- also his profile is hilarious [URL="http://steamcommunity.com/id/gamingwinkshd"][IG] GamingWinksHD[/URL] 23 Jul @ 1:31pm Hey Dude If You Know What Coderhire Is I Recently Posted A Job On There *(My Job: [URL="https://steamcommunity.com/linkfilter/?url=http://coderhire.com/jobs/view/5949)*"]http://coderhire.com/jobs/view/5949)*[/URL] And Every One Said It Was To Expensive, So I Said Fuck It, Literally Then I Went Round All My Steam Friends That Are Coders Asking If They Can Complete The Job For Me, They Said "Nope Pay $100 Then Il Do It" I Found A Website That Does Codes, I Posted It For The Same Budget Again, The Same Job (WarFare RP And $60) They Compelted The Job And Added More Things Than I Had Asked For, And Cheaper! $34.99! So If You Are A Server Owner Or Are Friends With A Server Owner Please Recommend The Site To Them. I Can Get You Guys 30% Cause After My Script We Are Actually Really Good Friends [URL="http://www.theonlinefreakz.wix.com/customzgamemodez"]www.theonlinefreakz.wix.com/customzgamemodez[/URL] his own website< if you check his website, some of his products say... Ever Played CoD Ghosts? Well Theres A Mission Where Your Lower Youself From A Building And Break Into A Room. I Re-Created This And I Made A SWEP That Does The Exact Same Thing But Better! he can somehow recreate that, but cant do a simple if statement
Example of chat-commands: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/chat_commands/chat_commands.lua.html[/url] A way to give guns based on user-group: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gamemode_logic/give_weapons_based_on_group.lua.html[/url] Gun-race logic - kills for upgrades: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gamemode_logic/gun_race/upgrade_weapons_for_kills.lua.html[/url] It doesn't take much for some of them to be converted to use steamid instead of group, etc.
well, ive taken some advice to learn lua a bit more in depth and heres what i've come up with overnight, not the same thing, a warn script [CODE] function warnPlayer ( ply, text, public ) if string.sub ( text, 1, 2 ) == "!w" then local target for _, v in pairs ( player.GetAll() ) do if string.find (v:Nick(), string.sub( text, 4)) then if not target then target = v v:PrintMessage ( HUD_PRINTTALK, "[" ..target:Nick().. "] Has Been Warned By: ["..ply:Nick().."]!" warn = warn + 1 warnTimes = warnTimes + 1 if warn == 2 then ply:PrintMessage (HUD_PRINTTALK, target:Nick() .. "Has" .. warn .. "Warnings And Will Now Be Kicked!" -- Add Kick In Here Soon.... end target:PrintMessage (HUD_PRINTTALK, "You've Got: [" ..warn..."] Warning(s). You've Been Warned: ["..warnTimes.."] Time(s) Before." end end end end end hook.Add ("PlayerSay", "warnPlayer", warnPlayer) [/CODE]
[QUOTE=TheCodingBoss;45607580]well, ive taken some advice to learn lua a bit more in depth and heres what i've come up with overnight, not the same thing, a warn script [CODE] function warnPlayer ( ply, text, public ) if string.sub ( text, 1, 2 ) == "!w" then local target for _, v in pairs ( player.GetAll() ) do if string.find (v:Nick(), string.sub( text, 4)) then if not target then target = v v:PrintMessage ( HUD_PRINTTALK, "[" ..target:Nick().. "] Has Been Warned By: ["..ply:Nick().."]!" warn = warn + 1 warnTimes = warnTimes + 1 if warn == 2 then ply:PrintMessage (HUD_PRINTTALK, target:Nick() .. "Has" .. warn .. "Warnings And Will Now Be Kicked!" -- Add Kick In Here Soon.... end target:PrintMessage (HUD_PRINTTALK, "You've Got: [" ..warn..."] Warning(s). You've Been Warned: ["..warnTimes.."] Time(s) Before." end end end end end hook.Add ("PlayerSay", "warnPlayer", warnPlayer) [/CODE][/QUOTE] Are you serious? Please tell me you are kidding... You are kidding right?
Why so many tabs? Also, you're not saving the warnings to the player in question... Here's it rewritten with my system and more "modular"... [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_warning_system/simple_warn_command.lua.html[/url] Usage: !w <target_player_name> <[reason]> to warn player. !warnings to print out all warnings. Warnings are RESET each map change / server-crash. It wouldn't take much to add a save feature. The warnings:Think function determines what to do after a warning ( basically if you want to kick based on count or ban.. etc ) Functions: [code]function warnings:GetAll( _p ) function warnings:Add( _p, _admin, _reason ) function warnings:Think( _p, _count ) function warnings:FindPlayer( _name ) function warnings:FindPlayerSteamID( _steam )[/code] Uses the chat command system I posted before. Hopefully this will help you see how to write things differently to prevent reusing code, modular design, etc..
[QUOTE=Acecool;45607955]snip[/QUOTE] To be honest, you shouldn't even bother. This guy can't even do simple things in Lua (Check his post history). His tactic is to bash random buttons on his keyboard, then proceeds to this very forum and copy/paste his precisely crafted code and expects us to fix it all.
[QUOTE=Tomvdr;45607986]To be honest, you shouldn't even bother. This guy can't even do simple things in Lua (Check his post history). His tactic is to bash random buttons on his keyboard, then proceeds to this very forum and copy/paste his precisely crafted code and expects us to fix it all.[/QUOTE] Sure, thecodingboss's code is funny as fuck i think my chair broke after reading his attempt, but everyone starts somewhere, if Acecool wants to help, then coding boss should be grateful [sp] I piss myself everytime I say his name [/sp]
I feel he literally got that from an old thread and renamed some things or "edited" it. Also from what pantera said this is him? [IMG]http://i57.tinypic.com/1zb4gpj.jpg[/IMG]
We now have a "request addon" thread for those that want to contribute so I have no problem with contributing to the community as long as the user takes something away from it like a better understanding so that eventually they'll be able to do the same thing. That is one of the reasons why I put so many comments into code I release.
[QUOTE=Acecool;45607999]We now have a "request addon" thread for those that want to contribute so I have no problem with contributing to the community as long as the user takes something away from it like a better understanding so that eventually they'll be able to do the same thing. That is one of the reasons why I put so many comments into code I release.[/QUOTE] But you only need so many comments because beginner coders can't read your cryptic code. The code should be clear and with well named variables so it allows the beginner to follow the code easily.
[QUOTE=Acecool;45607999]We now have a "request addon" thread for those that want to contribute so I have no problem with contributing to the community as long as the user takes something away from it like a better understanding so that eventually they'll be able to do the same thing. That is one of the reasons why I put so many comments into code I release.[/QUOTE]Where is this request thread?
I do show my coding standards: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_tutorial_quizzes/_coding_standards.lua.html[/url] to people that ask. I always keep certain variables always named the same ( except in certain situations, such as where there are 2 players like target/admin, then I'll deviate. I use _ before all "local" variables, except in loops like for k, v UNLESS it helps the "understanding" of the data or if the data contains an exact type. [editline]6th August 2014[/editline] [QUOTE=ShadowRanger;45608019]Where is this request thread?[/QUOTE] [url]http://facepunch.com/showthread.php?t=1414853[/url]
Sorry, you need to Log In to post a reply to this thread.