-
Posts
143 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Trust aka Tiffergan
-
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
This first way is easier, I added to accounts.Lua and everything is working, thanks -
not sure what you want but maybe this ?
-
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
my bad there is an error in line 8 on that setElementData https://prnt.sc/scajbc sorry for spamming i cant edit my post -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
and i now trying do this like that table = {"Milk","MP5A5","M4A1-S","AK-47","Soda Bottle","Pizza","AS50","Tent","Medium Tent","ACR","AR-15","M107","Pasta Can","Beans Can","Golf Club"} addEventHandler("onPlayerSpawn", root, function(lvl) local player = source if not lvl then lvl = getElementData(player, "lvl") or 0; end if lvl >= 1 then for i = 1, lvl do setElementData(player, "lvl", table[i], (getElementData(player,"lvl", table[i]) or 0) + 1); end end end); they're no errors, but still i dont have weapon and anyting ... -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
even i was trying like this addEventHandler("onPlayerLogin", getRootElement(), function() local level = getAccountData(getPlayerAccount(source), "lvl") or 0 if not level then return outputChatBox(" wrong lvl", source) end if level >= 1 then setElementData(source, "MP5A5", 1) elseif level >= 2 then setElementData(source, "Tent", 1) elseif level >= 3 then setElementData(source, "Milk", 1) elseif level >= 4 then setElementData(source, "Medic Kit", 1) elseif level >= 5 then setElementData(source, "Shovel", 1) end end); and function to test ElementData function test(plr) local data = getElementData(plr, "Tent") or 0 outputChatBox (data, plr) end addCommandHandler("spr", test) and when i will use SPR i will have 0 on chat, soi dont know what im doing wrong with that -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
so i was trying like this but none of this was working in accounts.Lua i was trying this option ( not everything at once ) addEventHandler("onPlayerDayZLogin", root, function() local lvl = getElementData(source, "lvl") or 0; if lvl then if lvl >= 1 then setElementData(player, "MP5A5", 1) elseif lvl >= 2 then setElementData(player, "Tent", 1) elseif lvl >= 3 then setElementData(player, "Milk", 1) elseif lvl >= 4 then setElementData(player, "Medic Kit", 1) elseif lvl >= 5 then setElementData(player, "Shovel", 1) end end end); table = {"Milk","MP5A5","M4A1-S","AK-47","Soda Bottle","Pizza","AS50","Tent","Medium Tent","ACR","AR-15","M107","Pasta Can","Beans Can","Golf Club"} addEventHandler("onPlayerDayZLogin", root, function(lvl) if not lvl then lvl = getElementData(source, "lvl") or 0; end if lvl >= 1 then for i = 1, lvl do setElementData(source, table[i], getElementData(source, table[i]) + 1); end end end); addEventHandler("onPlayerDayZLogin", root, function() local lvl = getElementData(source, "lvl") or 0; if lvl then if lvl >= 1 then setElementData("M4A1-S", 1) end end end); addEventHandler("onPlayerSpawn", root, function() local lvl = getElementData(source, "lvl") or 0; if lvl then if lvl > 1 then setElementData(source, "M4A1-S", 1) end end end); AND ON SERVER.Lua IN SCRIPT LEVEL I WAS TRYING THIS addEventHandler("onPlayerLevelUp", root, function(newlvl) if newlvl then if lvl >= 1 then setElementData(player, "MP5A5", 1) elseif lvl >= 2 then setElementData(player, "Tent", 1) elseif lvl >= 3 then setElementData(player, "Milk", 1) elseif lvl >= 4 then setElementData(player, "Medic Kit", 1) elseif lvl >= 5 then setElementData(player, "Shovel", 1) end end end); and none of this work, im just stupid i think... EDIT : i had no erros in DB -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
wow, lots of information, I will try to comprehend something and create something when I wake up, all night I tried to do it and now I go to sleep, If i will have problems i will write here , thanks again, I should get up around 6, cheers. -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
So, I was able to block the experience when you reach level 15, but I have a really big problem creating a function that will give you an item to start if you have enough level i was trying like that ( dont laught i know its bad ) if getElementData(player,'lvl') >= 9 then itemName == ("Milk", 1) addEventHandler ("onPlayerSpawn", getRootElement(), function() if getElementData(player,'lvl') > 9 then setElementData("Milk",1 ) help -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
Great, i will try to do this, cheers. -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
thanks i appreciate your help and last question, what function or event i need to use to do like max 30levels and award for hitting level, like if you hit level 5 you will get knife on respawn -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
i was using your script and that the result : https://streamable.com/vq61t3 -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
there is no bugs in db if im using my script or your but killing player not working, i got exp for zombie but cant get from killing player: https://streamable.com/8q10m4 -
[HELP] need help with exp when i kill player
Trust aka Tiffergan replied to Trust aka Tiffergan's topic in Scripting
I use 0.7 which you once made public, if I post a comment on this setElementData(killer1,"exp",tonumber(getElementData(killer1,"exp"))+50) script does not work, which is ridiculous because I am aware that I do not need it, but without it I do not add XP, and on the client side EXP: it doesn't change, if I do functions with zombies the way I did. It works, and i dont have errors in db, I only have a problem with killing players, because I don't get exp, and could you help me, how can I get exp for players? sorry for bad english :f -
local xpNeed = 100; -- E.g. 100 * lvl = XP you need to rank up! addEvent("onPlayerLevelUp", true); addEvent("onZombieGetsKilled", true) function addPlayerXp(player, xp) local acc = getPlayerAccount(player); local oldexp = getAccountData(acc, "exp") or 0; local oldlvl = getAccountData(acc, "lvl") or 1; local newlevel = oldlvl + 1; local newexp = oldexp + xp; setAccountData(acc, "exp", newexp); setElementData(player, "exp", newexp); if (newexp >= (oldlvl * xpNeed)) then outputChatBox("[Level-Up] Congratulations! New level "..newlevel.."!", player, 66, 134, 244); setAccountData(acc, "lvl", newlevel); setAccountData(acc, "exp", 0); setElementData(player, "exp", 0); setElementData(player, "lvl", newlevel); triggerEvent("onPlayerLevelUp", player, newlevel); end end addEventHandler("onPlayerLogin", root, function() local acc = getPlayerAccount(source); setElementData(source, "lvl", getAccountData(acc, "lvl") or 0); setElementData(source, "exp", getAccountData(acc, "exp") or 0); end); function rewardOnWasted ( killer ) local exp = getElementData(killer,"exp") local thelvl = getElementData(killer, "lvl") or 0; local theexp = getElementData(killer, "exp") or 0; if exp then setElementData(killer,"exp",tonumber(getElementData(killer,"exp"))+50) addPlayerXp(killer, 50) outputChatBox("Experience gained +50! total ".. tostring(((thelvl + 1) * xpNeed) - theexp -50).."!", killer ) else setElementData(killer,"exp",50) end end addEvent("onZombieGetsKilled", true) addEventHandler("onZombieGetsKilled", getRootElement(), rewardOnWasted) function rewardOnWasted1 ( killer1) --if there is a killer, and that killer is not the same person as whoever died if ( killer1 ) and ( killer1 ~= source ) then setElementData(killer1,"exp",tonumber(getElementData(killer1,"exp"))+50) addPlayerXp(killer1, 50) outputChatBox("Experience gained +50! total ".. tostring(((thelvl + 1) * xpNeed) - theexp -50)) else setElementData(killer1,"exp",50) end end addEvent("killDayZPlayer", true) addEventHandler ( "killDayZPlayer", getRootElement(), rewardOnWasted1 ) --attach the rewardOnWasted function to the relevant event Hi, I have a problem when I killing zombies, I get exp, but when I kill players I don't get it, anyone knows what the solution is?