Hey, Im brand new to Glua, and im creating a addon (not sure if public or not), but it essentialy lets the user type !v as opposed to !cloak with ULX
Bit pointless yes, however agein, im new to Glua and i dont know what im doing. So i launch the game (its in my addons folder (and yes in autorun)), and when i type !v, nothing happens, no errors, nothin.
Its located Serverside and heres the code:
[code]
--------------------
--SUPER VANISH 1.0--
------ Livaco ------
--------------------
// NOTE: DO NOT EDIT UNLESS YOU KNOW WHAT TO DO!!!
// Loading (doesent load anything, just to look cool)
print("Loading Supervanish...")
print("Loading Complete")
// Functions
// The reason this plugin requires ULX is becuse it only has !v trigger cloak, then !unv triggers uncloak.
// Cloak
hook.Add( "PlayerSay", "vanishenable", function( ply, text, team )
if ( string.sub( text, 1, 2 ) == "!v" ) then // Checks if the player says !v
// Runs in the console "ulx cloak (name)"
RunConsoleCommand("ulx cloak")
// Tells the player that they are in vanish
chat.AddText( Color( 0, 255, 0 ),"[SV] You activated vanish, type !unv to get out of vanish." )
end
end )
// Uncloak
hook.Add( "PlayerSay", "vanishdisable", function( ply, text, team )
if ( string.sub( text, 1, 4 ) === "!unv" ) then // Checks if the player says !unv
// Runs in the console "ulx uncloak"
RunConsoleCommand("ulx uncloak")
// Tells the player they are not vanished
chat.AddText( Color( 0, 255, 0 ),"[SV] You are no longer vanished." )
end
end )
// End of script
[/code]
Any help to why it doesent do anything is appreciated
Thanks
Livaco
For the uncloak code, run a check to see if the player is already cloaked. Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ChatPrint]Player:ChatPrint[/url] to send text to the player's chat box too.
Also, use -- for comments, not //.
[editline]8th April 2017[/editline]
And maybe run the same check on the first hook, too.
how would i run a check to see if the player is allready vanished??
Plus i updated my code to this:
[code]--------------------
--SUPER VANISH 1.0--
------ Livaco ------
--------------------
-- NOTE: DO NOT EDIT UNLESS YOU KNOW WHAT TO DO!!!
-- Loading (doesent load anything, just to look cool)
print("Loading Supervanish...")
print("Loading Complete")
-- Functions
-- Cloak
hook.Add( "PlayerSay", "vanishenable", function( ply, text, team )
if ( string.sub( text, 1, 2 ) == "!v" ) then -- Checks if the player says !v
-- Runs in the console "ulx cloak (name)"
RunConsoleCommand("ulx cloak")
-- Tells the player that they are in vanish
ply:ChatPrint( "[SV] You activated vanish, type !unv to get out of vanish." )
end
end )
-- Uncloak
hook.Add( "PlayerSay", "vanishdisable", function( ply, text, team )
if ( string.sub( text, 1, 4 ) === "!unv" ) then -- Checks if the player says !unv
-- Runs in the console "ulx uncloak"
RunConsoleCommand("ulx uncloak")
-- Tells the player they are not vanished
ply:ChatPrint( "[SV] You are no longer vanished." )
end
end )
-- End of script[/code]
[editline]8th April 2017[/editline]
Update: i fixed an error in the unv code, then i got this.
[SV] You activated vanish, type !unv to get out of vanish.
SuperAdmin| Livaco: !v
[SV] You are no longer vanished.
SuperAdmin| Livaco: !unv
I placed a camera, but i wasent cloaked in ULX, (yes i made sure i had ULX installed).
[editline]9th April 2017[/editline]
ANOTHER update:
Thanks to Owain, i was able to get it working perfectley, thanks everyone!
Sorry, you need to Log In to post a reply to this thread.