Jump to content

triggerServerEvent problems [SOLVED]


DRW

Recommended Posts

Posted (edited)

I'm making a kind of a primitive "mining" system that creates a ped so when it dies it sets +1 to an elementData, but it's not working, so I tried outputting to the chatbox a phrase, still not working, and nothing at the debugscript, what's happening?

Client

minepedt1 = createPed (0,-1321.708984375, 1353.8212890625, 119.890625,0) 
  
addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()),function() 
setElementDimension (minepedt1, 200) 
setPedFrozen (minepedt1,true) 
end) 
  
  
  
  
  
addEventHandler ("onClientPedWasted",minepedt1, function() 
triggerServerEvent ("give1",localPlayer) 
end) 
  
addEventHandler ("onClientPedDamage", minepedt1, function(attacker,weapon,bodypart) 
if (weapon == 5) then 
cancelEvent() 
setElementHealth (minepedt1,getElementHealth(minepedt1)-50) 
else 
cancelEvent() 
  
end 
end) 
  

Server

  
addEvent ("give1",true) 
addEventHandler ("give1",getRootElement(),function() 
local uut = getElementData (source,"ununtrium") 
setElementData (source,"ununtrium",uut+1) 
end) 
  
addEventHandler ("onPlayerLogin",getRootElement(),function() 
if not getAccountData (getPlayerAccount(source),"primera3") then 
setAccountData (getPlayerAccount(source), "ununtrium",0) 
setAccountData (getPlayerAccount(source), "ununquadium",0) 
setAccountData (getPlayerAccount(source), "ununpentium",0) 
setAccountData (getPlayerAccount(source), "ununhexium",0) 
setAccountData (getPlayerAccount(source), "ununseptium",0) 
setAccountData (getPlayerAccount(source), "ununoctium",0) 
setElementData (source, "ununtrium", 0) 
setElementData (source, "ununquadium", 0) 
setElementData (source, "ununpentium", 0) 
setElementData (source, "ununhexium", 0) 
setElementData (source, "ununseptium", 0) 
setElementData (source, "ununoctium", 0) 
setAccountData (getPlayerAccount(source),"primera3","true") 
else 
setElementData (source, "ununtrium", getAccountData (getPlayerAccount(source), "ununtrium")) 
setElementData (source, "ununquadium", getAccountData (getPlayerAccount(source), "ununquadium")) 
setElementData (source, "ununpentium", getAccountData (getPlayerAccount(source), "ununpentium")) 
setElementData (source, "ununhexium",getAccountData (getPlayerAccount(source), "ununhexium")) 
setElementData (source, "ununseptium",getAccountData (getPlayerAccount(source), "ununseptium")) 
setElementData (source, "ununoctium", getAccountData (getPlayerAccount(source), "ununoctium")) 
end 
end) 
  

Edited by Guest

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

Does onClientPedWasted trigger?

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
Does onClientPedWasted trigger?

Well, it dies when hit it several times, so I think yes.

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

You think? Try it then

addEventHandler ("onClientPedWasted",minepedt1, function() 
    outputChatBox"triggered" 
    triggerServerEvent ("give1",localPlayer) 
end) 

Also, try:

addEventHandler ("onClientPedWasted",root, function() 
    if source == minepedt1 then 
        triggerServerEvent ("give1",localPlayer) 
    end 
end) 

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
You think? Try it then
addEventHandler ("onClientPedWasted",minepedt1, function() 
    outputChatBox"triggered" 
    triggerServerEvent ("give1",localPlayer) 
end) 

Also, try:

addEventHandler ("onClientPedWasted",root, function() 
    if source == minepedt1 then 
        triggerServerEvent ("give1",localPlayer) 
    end 
end) 

Alright, thanks, the problem was that onClientPedWasted didn't trigger because of the onClientPedDamage event setting the ped's health to -25, so when it reached 0 it died but this was not triggered, but I need that, is there any way to make this event to get triggered even with setElementHealth(getElementHealth(minepedt1)-25)?

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

You can do small workaround.

If ped's health reaches zero (or less) then execute onClientPedWasted or whatever you want to name it.

-- This belongs to onClientPedDamage event. 
if getElementHealth(minepedt1) <= 0 then 
    triggerEvent("onClientPedWasted", minepedt1) 
end 

This is the only fix I could think of right now.

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
You can do small workaround.

If ped's health reaches zero (or less) then execute onClientPedWasted or whatever you want to name it.

-- This belongs to onClientPedDamage event. 
if getElementHealth(minepedt1) <= 0 then 
    triggerEvent("onClientPedWasted", minepedt1) 
end 

This is the only fix I could think of right now.

Thanks!

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

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