Jump to content

FIXED


spoty

Recommended Posts

Posted (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 by Guest
n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted
  
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.

Posted
  
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?

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted
  
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 ) 

Posted

Why use a loop to take the weapons?

takeAllWeapons 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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.

Posted
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

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted
  
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 ) 

Posted

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

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted
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.

Posted
  
--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.

And now Aurora is back again, pm for more info.

Ex. Lead dev & L6 Staff at AUR, NGC, MTA RP & SAA.

Ex. Developer at Community of Social Gamers - CSG

Ex Founder of International Gaming Community - IGC and Union of Individual Players- UIP

9o6E8.png Ab-47

Posted
  
--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. ;)

Posted
--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.

Posted
--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

n-560x95_FFFFFF_FFFFFF_000000_000000.png
  • Moderators
Posted
--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) 

The rEvolution is coming ...

Posted

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 ) 
  

n-560x95_FFFFFF_FFFFFF_000000_000000.png
  • Moderators
Posted

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) 

The rEvolution is coming ...

Posted

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) 

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted
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 ) 

Posted

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 ?

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted
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.

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...