bamby12 Posted March 10, 2011 Posted March 10, 2011 ok im trying to make a dx level system and it dosent work and i cant understand why it wont even show up anymore Client: function experience() GUIEditor_Label = {} local level = getElementData(source,"Level:") if (level) then GUIEditor_Label[1] = guiCreateLabel(266,696,197,21,"Level:"..level,false) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) else setElementData(source,"Level:", 1) local lvl = getElementData(source,"Level:") GUIEditor_Label[1] = guiCreateLabel(266,696,197,21,"Level:"..lvl,false) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) end local Experience = getElementData(source,"Experience:") if (Experience) then GUIEditor_Label[2] = guiCreateLabel(265,724,199,21,"Experience:"..Experience,false) guiLabelSetColor(GUIEditor_Label[2],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) else setElementData(source,"Experience", 1) local Experience = getElementData(source,"Experience:") GUIEditor_Label[2] = guiCreateLabel(265,724,199,21,"Experience:"..Experience,false) guiLabelSetColor(GUIEditor_Label[2],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) end end addEventHandler("onClientResourceStart", getRootElement(), experience) -- Direct X Drawing addEventHandler("onClientRender",root, function() dxDrawRectangle(263.0,722.0,205.0,27.0,tocolor(0,0,0,170),false) dxDrawRectangle(263.0,694.0,205.0,27.0,tocolor(0,0,0,170),false) end ) addEventHandler ( "onClientElementDataChange", root, function ( dataName, player ) local XP = getElementData(getLocalPlayer(),"Experience:") guiSetText ( GUIEditor_Label[2], "Experience:"..XP) guiSetVisible ( GUIEditor_Label[2], true ) local level = getElementData(getLocalPlayer(),"Level:") guiSetText ( GUIEditor_Label[1], "Level:"..level) guiSetVisible ( GUIEditor_label[1], true ) end end) Server: function outbreak(player) local account = getPlayerAccount(player) if (account) then local doob = getAccountData( player, "Experience:" ) local doob2 = getAccountData( player, "Level:") if (doob) then setElementData ( player, "Experience:", doob ) setElementData ( player, "Level:", doob2 ) else setElementData ( player, "Experience:", 0 ) setElementData ( player, "Level:", 0 ) end end end addEventHandler("onPlayerLogin", getRootElement(), outbreak) addEventHandler("onPlayerQuit", getRootElement(),quit) function quit(Player) local account = getPlayerAccount(Player) if (account) then local Experience = getElementData(Player,"Experience:") local Level = getElementData(Player,"Level:",Level) setAccountData(Player,"Experience:", Experience) setAccountData (Player,"Level:",Level) end end addEventHandler("onElementDataChange",getRootElement(),levelup) function levelup(Player) local XP = getElementData(Player,"Experience:") if XP == 25 then setElementData ( Player, "Level:", 2) outputChatBox ( Player, "You Are Now Level 2!", 0,255,0) end if XP == 75 then setElementData ( Player, "Level:", 3) outputChatBox ( Player, "You Are Now Level 3!", 0,255,0) end if XP == 150 then setElementData ( Player, "Level:", 4) outputChatBox ( Player, "You Are Now Level 4!", 0,255,0) end if XP == 300 then setElementData ( Player, "Level:", 5) outputChatBox ( Player, "You Are Now Level 5!", 0,255,0) end if XP == 425 then setElementData ( Player, "Level:", 6) outputChatBox ( Player, "You Are Now Level 6!", 0,255,0) end if XP == 650 then setElementData ( Player, "Level:", 7) outputChatBox ( Player, "You Are Now Level 7!", 0,255,0) end end function deanimated (ammo, attacker, weapon, bodypart) if (attacker) then if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then if (getElementData (source, "zombie") == true) then local XP = getElementData ( attacker, "Experience:" ) if XP ~= false then setElementData ( attacker, "Experience:", XP+math.random(2,5)) else setElementData ( attacker, "Experience:", 1 ) end end end end end addEventHandler("onPedWasted", resourceRoot, deanimated) any help appreciated thanks.
Castillo Posted March 10, 2011 Posted March 10, 2011 function outbreak() -- "source" is the player event. local account = getPlayerAccount(source) if (account) then local doob = getAccountData( source, "Experience:" ) local doob2 = getAccountData( source, "Level:") if (doob) then setElementData ( source, "Experience:", doob ) setElementData ( source, "Level:", doob2 ) else setElementData ( source, "Experience:", 0 ) setElementData ( source, "Level:", 0 ) end end end addEventHandler("onPlayerLogin", getRootElement(), outbreak) function quit() -- "source" is the player event. local account = getPlayerAccount(source) if (account) then local Experience = getElementData(source,"Experience:") local Level = getElementData(source,"Level:",Level) setAccountData(source,"Experience:", Experience) setAccountData (source,"Level:",Level) end end addEventHandler("onPlayerQuit", getRootElement(),quit) function levelup() local XP = getElementData(source,"Experience:") if XP == 25 then setElementData ( source, "Level:", 2) outputChatBox ( source, "You Are Now Level 2!", source,0,255,0) end if XP == 75 then setElementData ( source, "Level:", 3) outputChatBox ( source, "You Are Now Level 3!", 0,255,0) end if XP == 150 then setElementData ( source, "Level:", 4) outputChatBox ( source, "You Are Now Level 4!",source, 0,255,0) end if XP == 300 then setElementData ( source, "Level:", 5) outputChatBox ( source, "You Are Now Level 5!",source, 0,255,0) end if XP == 425 then setElementData ( source, "Level:", 6) outputChatBox ( source, "You Are Now Level 6!",source, 0,255,0) end if XP == 650 then setElementData ( source, "Level:", 7) outputChatBox ( source, "You Are Now Level 7!",source,0,255,0) end end addEventHandler("onElementDataChange",getRootElement(),levelup) function deanimated (ammo, attacker, weapon, bodypart) if (attacker) then if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then if (getElementData (source, "zombie") == true) then local XP = getElementData ( attacker, "Experience:" ) if XP ~= false then setElementData ( attacker, "Experience:", XP+math.random(2,5)) else setElementData ( attacker, "Experience:", 1 ) end end end end end addEventHandler("onPedWasted", resourceRoot, deanimated)
Moderators Citizen Posted March 10, 2011 Moderators Posted March 10, 2011 Do you see my PMs bamby12 ???
bamby12 Posted March 10, 2011 Author Posted March 10, 2011 yeah didnt see u was online though pm me please
Castillo Posted March 10, 2011 Posted March 10, 2011 I fixed the server side part, since i'm busy right now, i can't check the client side part.
bamby12 Posted March 11, 2011 Author Posted March 11, 2011 NVM it works now thanks, how can i save element data though? i tried: function outbreak() local account = getPlayerAccount(source) if (account) then local doob = getAccountData( source, "Experience" ) local doob2 = getAccountData( source, "Level") if (doob) then setElementData ( source, "Experience", tonumber(doob) ) setElementData ( source, "Level", tonumber(doob2) ) else setElementData ( source, "Experience", 0 ) setElementData ( source, "Level", 0 ) end end end addEventHandler("onPlayerLogin", getRootElement(), outbreak) function quit() local account = getPlayerAccount(source) if (account) then local Experience = getElementData(source,"Experience") local Level = getElementData(source,"Level",Level) setAccountData(source,"Experience", Experience) setAccountData (source,"Level",Level) end end addEventHandler("onPlayerQuit", getRootElement(),quit)
Moderators Citizen Posted March 11, 2011 Moderators Posted March 11, 2011 NVM it works now thanks, how can i save element data though? i tried: He wanted to say: "Yesterday night, Citizen helped me to fix all bugs and to transform the absolute position to a relativ postition (we make 2 converters one for the labels and one for the dxDrawRectangle ). And we have finished this script at 4:30 AM. But now how I can save the datas ?" It's that you wanted to say ? Isn't it ?
bamby12 Posted March 11, 2011 Author Posted March 11, 2011 yeah thats exactly what i meant to say but still i cant see why the save don't work Thanks for the 6 hours of pain and suffering on notepad++ last night Citizen much appreciated now it works
Moderators Citizen Posted March 11, 2011 Moderators Posted March 11, 2011 yeah thats exactly what i meant to say but still i cant see why the save don't work Thanks for the 6 hours of pain and suffering on notepad++ last night Citizen much appreciated now it works No problem but I'm a little bit tired
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