^Dev-PoinT^ Posted December 2, 2011 Share Posted December 2, 2011 Hi all see this i take it From Zombie Gamemode i want if Player kill a player get 1 EXp every kill = +1 EXP Server Side function a () local account = getPlayerAccount(p) setAccountData(account,"Kills",true) local old = getAccountData(account,"EXP") or 0 setAccountData(account,"EXP",old+5) triggerClientEvent(p,"expOnChange",getRootElement(),old+5,5) end addEventHandler ( "onPlayerWasted", getRootElement(), a ) function deanimated( ammo, attacker, weapon, bodypart ) if (attacker) then if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then if (getElementData (source, "Kills") == true) then local isExp = getAccountData(getPlayerAccount(attacker),"EXP") local expr = false if isExp then expr = tonumber(isExp) + 1 else expr = 1 end triggerClientEvent ( attacker, "expOnChange", getRootElement(), expr, 1) givePlayerMoney(attacker,tonumber(get("zombiegamemode.Reward"))+math.random(-100,100)) setPedOnFire(source,false) setPedHeadless(source,false) local attacker2 = getPlayerAccount(attacker) local oldZcount = getAccountData(attacker2,"EXP") if oldZcount ~= false then setAccountData ( attacker2, "EXP", oldZcount+1 ) setElementData( attacker, "EXP", oldZcount+1 ) setPlayerAnnounceValue(attacker,"EXP",tostring(oldZcount+1)) triggerEvent ( "onPlayerWasted", source, attacker, weapon, bodypart ) else setAccountData ( attacker2, "EXP", 1 ) setPlayerAnnounceValue(attacker,"score","1") setElementData( attacker, "EXP", 1 ) triggerEvent ( "onPlayerWasted", source, attacker, weapon, bodypart ) end end end end end addEventHandler("onPlayerWasted", resourceRoot, deanimated) Client Side unction clientsetupstarter(startedresource) if startedresource == getThisResource() then setTimer ( clientsetup, 1234, 1) MainClientTimer1 = setTimer ( zombie_check, 1000, 0) expLabel = guiCreateLabel(0.777,0.22,0.1708,0.0963,"EXP gained: ??\nTotal EXP: ??\nLevel: Unknown",true) guiLabelSetColor(expLabel,0,255,0) guiLabelSetVerticalAlign(expLabel,"top") guiLabelSetHorizontalAlign(expLabel,"left",false) guiSetFont(expLabel,"clear-normal") end end local ttlgnd = 0 function expChange(expr,gained) ttlgnd = ttlgnd+gained guiSetText(expLabel,"") local level,levelnum = "#0 - Newbie",0 if expr >= 10 then level = "#1 - Novice" levelnum = 1 end if expr >= 20 then level = "#2 - Average" levelnum = 2 end if expr >= 100 then level = "#3 - Good" levelnum = 3 end if expr >= 200 then level = "#4 - Killer" levelnum = 4 end if expr >= 500 then level = "#5 - Skilled" levelnum = 5 end if expr >= 1000 then level = "#6 - Elite" levelnum = 6 end if expr >= 2000 then level = "#7 - Senior" levelnum = 7 end if expr >= 3000 then level = "#8 - Amazing" levelnum = 8 end if expr >= 5000 then level = "#9 - Pro" levelnum = 9 end if expr >= 10000 then level = "#10 - Godlike" levelnum = 10 end if expr >= 20000 then level = "#11 - God" levelnum = 11 end guiSetText(expLabel,"EXP gained: "..ttlgnd.." (+"..gained..")\nTotal EXP: "..expr.."\nLevel: "..level) setElementData(getLocalPlayer(),"Level",level) setElementData(getLocalPlayer(),"levelnum",levelnum) end addEvent( "expOnChange", true ) addEventHandler( "expOnChange", getRootElement(), expChange ) addEventHandler("onClientResourceStart", getRootElement(), clientsetupstarter) Link to comment
unknooooown Posted December 2, 2011 Share Posted December 2, 2011 Seems you are in way over your head Dev_Point Another thing.. Are you even sure that your script has access to ' "zombiegamemode.Reward" ' ? If I was you, I would shut down and delete this resource right away. If you want an experience/level system for your gamemode, I would recommend that you read how other people have done it in the past. Not just MTA players, but for all games that have those elements included. Could be games like World of Warcraft. There is TONS of info about the setup on the web. Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 You are right but iam not good as you are i have a Gamemode but its Need EXP/Level System Link to comment
unknooooown Posted December 2, 2011 Share Posted December 2, 2011 You are right but iam not good as you are i have a Gamemode but its Need EXP/Level System I know bud. I just wanted to remind you that you have to be realistic sometimes. I know that you really want your gamemode finished, but if some of the elements are too hard for you to do on your own, then you have to wait or get someone to help you finish it. I know that you are putting a lot of work into your project, which is just fine. But in the end, wouldnt it be a better feeling to have something you have created on your own, rather than to have 90% resources created by others? Link to comment
TAPL Posted December 2, 2011 Share Posted December 2, 2011 wtf? addEventHandler("onPlayerWasted", resourceRoot, deanimated) Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 Hi all i have Made This Server side if killer kill a player get +1 EXP every time he kill P.S with Tabel for the EXP exports.scoreboard:scoreboardAddColumn("EXP") give = {{[1] = "1"}, {{[2] = "2"}}, {{[3] = "3"}}} function win(ammo, killer, weapon, bodypart) local H = getElementData(killer, "EXP") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) if killer and killer ~=source then setElementData(killer, "EXP", tonumber(give) + 1) outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 EXP", getRootElement(), 255, 255, 0, false) end end addEventHandler("onPlayerWasted", getRootElement(), Win) Link to comment
Aibo Posted December 2, 2011 Share Posted December 2, 2011 viewtopic.php?f=91&t=37584 you already have one topic about this. if you've found another place to rip off another script it doesnt mean you need another topic for it. Link to comment
Castillo Posted December 2, 2011 Share Posted December 2, 2011 Why do you need a table to just add +1 to a element data? exports.scoreboard:scoreboardAddColumn("EXP") function win(ammo, killer, weapon, bodypart) local H = getElementData(killer, "EXP") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) if killer and killer ~=source then setElementData(killer, "EXP", tonumber(H)+1) outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 EXP", getRootElement(), 255, 255, 0, false) end end addEventHandler("onPlayerWasted", getRootElement(), Win) Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 not just +1 i made the table for 1 = +1 2 = +1 3= +1 .... 10/EXP you get it? exports.scoreboard:scoreboardAddColumn("EXP") give = {{[1] = "1"}, {{[2] = "2"}}, {{[3] = "3"}}} function win(ammo, killer, weapon, bodypart) local H = getElementData(killer, "EXP") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) if killer and killer ~=source then setElementData(killer, "EXP", tonumber(give) + 1) outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 EXP", getRootElement(), 255, 255, 0, false) end end addEventHandler("onPlayerWasted", getRootElement(), Win) Link to comment
Castillo Posted December 2, 2011 Share Posted December 2, 2011 No, I don't get what do you want, but what I get is that you want to add +1 exp point each time you kill a player, and that's what my code does. Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 i want a tabel limet is 10 EXP the Player gets EXP Last EXP is 10 Link to comment
Castillo Posted December 2, 2011 Share Posted December 2, 2011 You want the player to get +1 EXP point until it reaches 10? Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 yes that is right Link to comment
Castillo Posted December 2, 2011 Share Posted December 2, 2011 exports.scoreboard:scoreboardAddColumn("EXP") function win(ammo, killer, weapon, bodypart) local H = getElementData(killer, "EXP") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) if killer and killer ~=source then if tonumber(H) < 10 then setElementData(killer, "EXP", tonumber(H)+1) end outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 EXP", getRootElement(), 255, 255, 0, false) end end addEventHandler("onPlayerWasted", getRootElement(), Win) Should work. Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 and i can remove 10 and put any number? for example 1000?? Link to comment
Castillo Posted December 2, 2011 Share Posted December 2, 2011 Yes, you can, that's pretty obviously. Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 i last thing if EXP = 10 then setPlayerLevel "lvl1" .... exports.scoreboard:scoreboardAddColumn("EXP") exports.scoreboard:scoreboardAddColumn("Level") function win(ammo, killer, weapon, bodypart) local H = getElementData(killer, "EXP") local S = getElementData(killer, "Level") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) if killer and killer ~=source then if tonumber(H) < 10 then setElementData(killer, "Level", "Lvl 1") if tonumber(S) < 20 then setElementData(killer, "Level", "Lvl 2") if tonumber(S) < 30 then setElementData(killer, "Level", "Lvl 3") if tonumber(S) < 40 then setElementData(killer, "Level", "Lvl 4") if tonumber(S) < 50 then setElementData(killer, "Level", "Lvl 5") if tonumber(S) < 60 then setElementData(killer, "Level", "Lvl 6") setElementData(killer, "EXP", tonumber(H)+1) end outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 EXP", getRootElement(), 255, 255, 0, false) end end addEventHandler("onPlayerWasted", getRootElement(), Win) Link to comment
Castillo Posted December 2, 2011 Share Posted December 2, 2011 (edited) exports.scoreboard:scoreboardAddColumn("EXP") exports.scoreboard:scoreboardAddColumn("Level") function win(ammo, killer, weapon, bodypart) local H = getElementData(killer, "EXP") local S = getElementData(killer, "Level") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) if killer and killer ~=source then setElementData(killer, "EXP", tonumber(H)+1) if tonumber(H) == 10 then setElementData(killer, "Level", "Lvl 1") elseif tonumber(H) == 20 then setElementData(killer, "Level", "Lvl 2") elseif tonumber(H) == 30 then setElementData(killer, "Level", "Lvl 3") elseif tonumber(H) == 40 then setElementData(killer, "Level", "Lvl 4") elseif tonumber(H) == 50 then setElementData(killer, "Level", "Lvl 5") elseif tonumber(H) == 60 then setElementData(killer, "Level", "Lvl 6") end outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 EXP", getRootElement(), 255, 255, 0, false) end end addEventHandler("onPlayerWasted", getRootElement(), Win) Edited December 2, 2011 by Guest Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 (edited) server.lua:27: 'end' expected (to close 'if' at line 15) near '' exports.scoreboard:scoreboardAddColumn("EXP") exports.scoreboard:scoreboardAddColumn("Level") function win(ammo, killer, weapon, bodypart) local H = getElementData(killer, "EXP") local S = getElementData(killer, "Level") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) if killer and killer ~=source then setElementData(killer, "EXP", tonumber(H)+1) if tonumber(H) == 10 then setElementData(killer, "Level", "Lvl 1") if tonumber(H) == 20 then setElementData(killer, "Level", "Lvl 2") if tonumber(H) == 30 then setElementData(killer, "Level", "Lvl 3") if tonumber(H) == 40 then setElementData(killer, "Level", "Lvl 4") if tonumber(H) == 50 then setElementData(killer, "Level", "Lvl 5") if tonumber(H) == 60 then setElementData(killer, "Level", "Lvl 6") end outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 EXP", getRootElement(), 255, 255, 0, false) end addEventHandler( "onPlayerWasted", getRootElement(), Win) Edited December 2, 2011 by Guest Link to comment
Castillo Posted December 2, 2011 Share Posted December 2, 2011 (edited) You removed one 'end'. exports.scoreboard:scoreboardAddColumn("EXP") exports.scoreboard:scoreboardAddColumn("Level") function win(ammo, killer, weapon, bodypart) local H = getElementData(killer, "EXP") local S = getElementData(killer, "Level") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) if killer and killer ~=source then setElementData(killer, "EXP", tonumber(H)+1) if tonumber(H) == 10 then setElementData(killer, "Level", "Lvl 1") elseif tonumber(H) == 20 then setElementData(killer, "Level", "Lvl 2") elseif tonumber(H) == 30 then setElementData(killer, "Level", "Lvl 3") elseif tonumber(H) == 40 then setElementData(killer, "Level", "Lvl 4") elseif tonumber(H) == 50 then setElementData(killer, "Level", "Lvl 5") elseif tonumber(H) == 60 then setElementData(killer, "Level", "Lvl 6") end outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 EXP", getRootElement(), 255, 255, 0, false) end end addEventHandler( "onPlayerWasted", getRootElement(), win) Edited December 3, 2011 by Guest Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 I am sorry to make you tired with me I owe you my friend do you want mony for this help i give you My GameMode is 85% thx to You! Link to comment
Castillo Posted December 2, 2011 Share Posted December 2, 2011 I'm here to help, I don't want a reward for it. Link to comment
^Dev-PoinT^ Posted December 2, 2011 Author Share Posted December 2, 2011 ok Thx Man Topic Closed now the EXP/Level its easy For Me befour i know them they was hard to Make lol Link to comment
Aibo Posted December 3, 2011 Share Posted December 3, 2011 srsly, how does it work with function named "win" and "Win" at event handler Link to comment
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