Jump to content

FIXED


spoty

Recommended Posts

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 by Guest
Link to comment
  
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.

Link to comment
  
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?

Link to comment
  
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 ) 

Link to comment
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 now

after i finished the client side and meta.xml

hope it works

Its not client side script, its server side.

Link to comment
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 now

after 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

Link to comment
  
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 ) 

Link to comment
  
--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.

Link to comment
  
--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. ;)

Link to comment
--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.

Link to comment
--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 :D

only for some reason i dont get godmode when i do /afk

Link to comment
  • Moderators
--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) 

Link to comment

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 ) 
  

Link to comment
  • Moderators

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) 

Link to comment

i think i am confused right now :S

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) 

Link to comment
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 ) 
  

  
 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 ) 

Link to comment

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 ?

Link to comment
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.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...