spoty Posted March 11, 2014 Posted March 11, 2014 (edited) hi who can help me? i have maded an teleporter but how can i create something like when user use telporter it take's all his weapons away and get godmode and cant get any weapon? please who can help me this is what i have now addCommandHandler( "afk", function( player ) setElementPosition( player, 1904.8403320313, 717.12438964844, 49.214366912842 ) outputChatBox( "You are now in Afk zone", player, 0, 255, 0 ) function godmod (Player) Player = getLocalPlayer() end end addEventHandler("onClientPlayerDamage", getRootElement(), godmod) end ) ) Edited March 13, 2014 by Guest
Moderators Citizen Posted March 11, 2014 Moderators Posted March 11, 2014 Don't define a function inside another one.
Anubhav Posted March 11, 2014 Posted March 11, 2014 addCommandHandler( "afk", function( player ) setElementPosition( player, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( player , true ) outputChatBox( "You are now in Afk zone", player, 0, 255, 0 ) end ) ) It will freeze him. And he can't shoot . He can only move the camera afaik.
spoty Posted March 11, 2014 Author Posted March 11, 2014 addCommandHandler( "afk", function( player ) setElementPosition( player, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( player , true ) outputChatBox( "You are now in Afk zone", player, 0, 255, 0 ) end ) ) It will freeze him. And he can't shoot . He can only move the camera afaik. no we have maded an afk zone where you can walk and chill but i wanne make it like you geth there with /afk as teleporter and when you do /afk you get godmode and take off all weapons or isnt that possible?
Saml1er Posted March 11, 2014 Posted March 11, 2014 addCommandHandler( "afk", function( player ) setElementPosition( player, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( player , true ) outputChatBox( "You are now in Afk zone", player, 0, 255, 0 ) end ) ) It will freeze him. And he can't shoot . He can only move the camera afaik. no we have maded an afk zone where you can walk and chill but i wanne make it like you geth there with /afk as teleporter and when you do /afk you get godmode and take off all weapons or isnt that possible? Yes. addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) for i=1, 46 do takeWeapon( thePlayer, i ) end setElementData ( thePlayer, "GodO.Health", "yep!" ) end ) addEventHandler ("onPlayerDamage", getRootElement(), function () if getElementData ( source, "GodO.Health" ) == "yep!" then cancelEvent() end )
Castillo Posted March 11, 2014 Posted March 11, 2014 Why use a loop to take the weapons? takeAllWeapons
spoty Posted March 11, 2014 Author Posted March 11, 2014 i go try that now after i finished the client side and meta.xml hope it works
Saml1er Posted March 11, 2014 Posted March 11, 2014 Why use a loop to take the weapons? takeAllWeapons Oh thank you, I searched for it but Idk I couldn't find it. Here again: addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) if takeAllWeapons ( thePlayer ) then setElementData ( thePlayer, "GodO.Health", "yep!" ) end end ) addEventHandler ("onPlayerDamage", getRootElement(), function () if getElementData ( source, "GodO.Health" ) == "yep!" then cancelEvent() end ) i go try that nowafter i finished the client side and meta.xml hope it works Its not client side script, its server side.
spoty Posted March 11, 2014 Author Posted March 11, 2014 i know i just sayed client in place of server sometimes i am just dump as f*ck
spoty Posted March 11, 2014 Author Posted March 11, 2014 Why use a loop to take the weapons? takeAllWeapons Oh thank you, I searched for it but Idk I couldn't find it. Here again: addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) if takeAllWeapons ( thePlayer ) then setElementData ( thePlayer, "GodO.Health", "yep!" ) end end ) addEventHandler ("onPlayerDamage", getRootElement(), function () if getElementData ( source, "GodO.Health" ) == "yep!" then cancelEvent() end ) i go try that nowafter i finished the client side and meta.xml hope it works Its not client side script, its server side. and if i wanne make a teleporter to main spawn like addCommandHandler( "back", function ( thePlayer ) setElementPosition( thePlayer, -2026.7408447266, 156.45680236816, 29.0390625 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now Out Afk zone", thePlayer, 255, 0, 0 ) and also take off god mode then
Saml1er Posted March 11, 2014 Posted March 11, 2014 addCommandHandler( "back", function ( thePlayer ) setElementPosition( thePlayer, -2026.7408447266, 156.45680236816, 29.0390625 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now Out Afk zone", thePlayer, 255, 0, 0 ) setElementData ( thePlayer, "GodO.Health", nil ) -- this will remove god mode end )
spoty Posted March 11, 2014 Author Posted March 11, 2014 i am soo sorry guys but can you guys mayby help me to make the client side i fail alot i am pretty noob at scripting
Saml1er Posted March 11, 2014 Posted March 11, 2014 i am soo sorry guys but can you guys mayby help me to make the client side i fail alot i am pretty noob at scripting This subforum is meant to help others so just ask your question and we'll help you.
Ab-47 Posted March 12, 2014 Posted March 12, 2014 --Client addCommandHandler("afk", function (player) setElementPosition(player, 1904.8403320313, 717.12438964844, 49.214366912842) outputChatBox( "You are now in Afk zone", player, 0, 255, 0 ) setElementData(player, "afk.godmode", true) setElementData(player, "afk.withinZone", true) triggerServerEvent("afk.takeWeps", root, player) end ) function onHit(plr) if (plr and isElement(plr) and getElementType(plr) == "player") then if (getElementData(plr, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit) --Server function takeWeps() takeAllWeapons(localPlayer) end addEvent("afk.takeWeps", true) addEventHandler("afk.takeWeps", root, takeWeps) Not tested, let me know if there's any errors.
Saml1er Posted March 12, 2014 Posted March 12, 2014 --Client addCommandHandler("afk", function (player) setElementPosition(player, 1904.8403320313, 717.12438964844, 49.214366912842) outputChatBox( "You are now in Afk zone", player, 0, 255, 0 ) setElementData(player, "afk.godmode", true) setElementData(player, "afk.withinZone", true) triggerServerEvent("afk.takeWeps", root, player) end ) function onHit(plr) if (plr and isElement(plr) and getElementType(plr) == "player") then if (getElementData(plr, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit) --Server function takeWeps() takeAllWeapons(localPlayer) end addEvent("afk.takeWeps", true) addEventHandler("afk.takeWeps", root, takeWeps) Not tested, let me know if there's any errors. You've mixed localPlayer and player.
WhoAmI Posted March 12, 2014 Posted March 12, 2014 --client addCommandHandler("afk", function () setElementPosition(localPlayer, 1904.8403320313, 717.12438964844, 49.214366912842) outputChatBox( "You are now in Afk zone", localPlayer, 0, 255, 0 ) setElementData(localPlayer, "afk.godmode", true) setElementData(localPlayer, "afk.withinZone", true) triggerServerEvent("afk.takeWeps", localPlayer) end ) function onHit(plr) if (plr and isElement(plr) and getElementType(plr) == "player") then if (getElementData(plr, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit) --Server function takeWeps() takeAllWeapons(source) end addEvent("afk.takeWeps", true) addEventHandler("afk.takeWeps", root, takeWeps) That should work.
spoty Posted March 12, 2014 Author Posted March 12, 2014 --client addCommandHandler("afk", function () setElementPosition(localPlayer, 1904.8403320313, 717.12438964844, 49.214366912842) outputChatBox( "You are now in Afk zone", localPlayer, 0, 255, 0 ) setElementData(localPlayer, "afk.godmode", true) setElementData(localPlayer, "afk.withinZone", true) triggerServerEvent("afk.takeWeps", localPlayer) end ) function onHit(plr) if (plr and isElement(plr) and getElementType(plr) == "player") then if (getElementData(plr, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit) --Server function takeWeps() takeAllWeapons(source) end addEvent("afk.takeWeps", true) addEventHandler("afk.takeWeps", root, takeWeps) That should work. it working great only for some reason i dont get godmode when i do /afk
Moderators Citizen Posted March 12, 2014 Moderators Posted March 12, 2014 --client addCommandHandler("afk", function () setElementPosition(localPlayer, 1904.8403320313, 717.12438964844, 49.214366912842) outputChatBox( "You are now in Afk zone", localPlayer, 0, 255, 0 ) setElementData(localPlayer, "afk.godmode", true) setElementData(localPlayer, "afk.withinZone", true) triggerServerEvent("afk.takeWeps", localPlayer) end ) function onHit(plr) if (plr and isElement(plr) and getElementType(plr) == "player") then if (getElementData(plr, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit) --Server function takeWeps() takeAllWeapons(source) end addEvent("afk.takeWeps", true) addEventHandler("afk.takeWeps", root, takeWeps) That should work. Should use source the player that have been hit, not the attacker: function onHit() if (source and isElement(source) and getElementType(source) == "player") then if (getElementData(source, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit)
spoty Posted March 12, 2014 Author Posted March 12, 2014 ok now its working with god mode but now i have a error when i do /afk ERROR: Client (NL|Spoty) triggered serverside event afk.takeWeps, but event is not added serverside addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , false ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) end ) function takeWeps() takeAllWeapons(source) end function takeWeps() addEvent("afk.takeWeps", true) addEventHandler("afk.takeWeps", root, takeWeps) setElementData ( thePlayer, "afk.godmode", "true" ) end addEventHandler ("onPlayerDamage", getRootElement(), function () if getElementData ( source, "afk.godmode" ) == "true" then cancelEvent() end end ) addCommandHandler( "back", function ( thePlayer ) setElementPosition( thePlayer, -2026.7408447266, 156.45680236816, 29.0390625 ) setElementFrozen ( thePlayer , false ) outputChatBox( "You are now Out Afk zone", thePlayer, 255, 0, 0 ) setElementData ( thePlayer, "afk.godmode", nill ) -- this will remove god mode end )
Moderators Citizen Posted March 12, 2014 Moderators Posted March 12, 2014 Omg, your code is totally dirty ! Copy this code again: --client addCommandHandler("afk", function () setElementPosition(localPlayer, 1904.8403320313, 717.12438964844, 49.214366912842) outputChatBox( "You are now in Afk zone", localPlayer, 0, 255, 0 ) setElementData(localPlayer, "afk.godmode", true) setElementData(localPlayer, "afk.withinZone", true) triggerServerEvent("afk.takeWeps", localPlayer) end ) function onHit(plr) if (plr and isElement(plr) and getElementType(plr) == "player") then if (getElementData(plr, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit) --Server function takeWeps() takeAllWeapons(source) end addEvent("afk.takeWeps", true) addEventHandler("afk.takeWeps", root, takeWeps) Lines 23 to 27 has to be on serverside. and replace lines 12 to 19 by mine: function onHit() if (source and isElement(source) and getElementType(source) == "player") then if (getElementData(source, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit)
spoty Posted March 12, 2014 Author Posted March 12, 2014 i think i am confused right now so i only need to use --client addCommandHandler("afk", function () setElementPosition(localPlayer, 1904.8403320313, 717.12438964844, 49.214366912842) outputChatBox( "You are now in Afk zone", localPlayer, 0, 255, 0 ) setElementData(localPlayer, "afk.godmode", true) setElementData(localPlayer, "afk.withinZone", true) triggerServerEvent("afk.takeWeps", localPlayer) end ) function onHit(plr) if (plr and isElement(plr) and getElementType(plr) == "player") then if (getElementData(plr, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit) and --server function onHit() if (source and isElement(source) and getElementType(source) == "player") then if (getElementData(source, "afk.godmode") == true) then cancelEvent() end end end addEventHandler("onClientPlayerDamage", root, onHit)
Saml1er Posted March 12, 2014 Posted March 12, 2014 ok now its working with god mode but now i have a error when i do /afkERROR: Client (NL|Spoty) triggered serverside event afk.takeWeps, but event is not added serverside addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , false ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) end ) function takeWeps() takeAllWeapons(source) end function takeWeps() addEvent("afk.takeWeps", true) addEventHandler("afk.takeWeps", root, takeWeps) setElementData ( thePlayer, "afk.godmode", "true" ) end addEventHandler ("onPlayerDamage", getRootElement(), function () if getElementData ( source, "afk.godmode" ) == "true" then cancelEvent() end end ) addCommandHandler( "back", function ( thePlayer ) setElementPosition( thePlayer, -2026.7408447266, 156.45680236816, 29.0390625 ) setElementFrozen ( thePlayer , false ) outputChatBox( "You are now Out Afk zone", thePlayer, 255, 0, 0 ) setElementData ( thePlayer, "afk.godmode", nill ) -- this will remove god mode end ) setElementData ( thePlayer, "afk.godmode", nil ) Line 35 and takeAllWeapons is server side function. Just tell me why do want client side script since its possible to script it in server side. The code I posted was server side, you can use it. addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) if takeAllWeapons ( thePlayer ) then setElementData ( thePlayer, "GodO.Health", "yep!" ) end end ) addEventHandler ("onPlayerDamage", getRootElement(), function () if getElementData ( source, "GodO.Health" ) == "yep!" then cancelEvent() end end ) addCommandHandler( "back", function ( thePlayer ) if isElementFrozen (thePlayer ) then setElementPosition( thePlayer, -2026.7408447266, 156.45680236816, 29.0390625 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now Out Afk zone", thePlayer, 255, 0, 0 setElementData ( thePlayer, "GodO.Health", nil ) setElementFrozen (thePlayer, false ) end end )
spoty Posted March 12, 2014 Author Posted March 12, 2014 ok so if i just only use addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , false ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) if takeAllWeapons ( thePlayer ) then setElementData ( thePlayer, "GodO.Health", "yep!" ) end end ) addEventHandler ("onPlayerDamage", getRootElement(), function () if getElementData ( source, "GodO.Health" ) == "yep!" then cancelEvent() end end ) addCommandHandler( "back", function ( thePlayer ) if isElementFrozen (thePlayer ) then setElementPosition( thePlayer, -2026.7408447266, 156.45680236816, 29.0390625 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now Out Afk zone", thePlayer, 255, 0, 0 ) setElementData ( thePlayer, "GodO.Health", nil ) setElementFrozen (thePlayer, false ) end end ) it works only god mode not but that isnt a big prob and is it possible to dissable players in afk zone to spawn weapons? like dissable F1 and /wp ?
Saml1er Posted March 12, 2014 Posted March 12, 2014 ok so if i just only use addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , false ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) if takeAllWeapons ( thePlayer ) then setElementData ( thePlayer, "GodO.Health", "yep!" ) end end ) addEventHandler ("onPlayerDamage", getRootElement(), function () if getElementData ( source, "GodO.Health" ) == "yep!" then cancelEvent() end end ) addCommandHandler( "back", function ( thePlayer ) if isElementFrozen (thePlayer ) then setElementPosition( thePlayer, -2026.7408447266, 156.45680236816, 29.0390625 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now Out Afk zone", thePlayer, 255, 0, 0 ) setElementData ( thePlayer, "GodO.Health", nil ) setElementFrozen (thePlayer, false ) end end ) it works only god mode not but that isnt a big prob and is it possible to dissable players in afk zone to spawn weapons? like dissable F1 and /wp ? You mean make them invisible? Anyways about the god mode, try this. -- server side addCommandHandler( "afk", function ( thePlayer ) setElementPosition( thePlayer, 1904.8403320313, 717.12438964844, 49.214366912842 ) setElementFrozen ( thePlayer , false ) outputChatBox( "You are now in Afk zone", thePlayer, 0, 255, 0 ) takeAllWeapons ( thePlayer ) setElementData ( thePlayer, "GodO.Health", true ) end ) addCommandHandler( "back", function ( thePlayer ) if isElementFrozen (thePlayer ) then setElementPosition( thePlayer, -2026.7408447266, 156.45680236816, 29.0390625 ) setElementFrozen ( thePlayer , true ) outputChatBox( "You are now Out Afk zone", thePlayer, 255, 0, 0 ) setElementData ( thePlayer, "GodO.Health", nil ) setElementFrozen (thePlayer, false ) end end ) -- client side addEventHandler ("onClientPlayerDamage", getRootElement(), function () if getElementData ( source, "GodO.Health" ) then cancelEvent() end end ) EDIT: I just read wiki and found this. It should be noted that this event is not triggered when attacked by a team member if friendly fire is enabled. It should also be noted that canceling this event has no effect. Cancel the client-side event onClientPlayerDamage instead. EDIT2: Copy the code again.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now