Jump to content

Rank system [HELP]


Sande

Recommended Posts

Hello, i have been created a rank system but somereason it doesnt working. No errors or anything in debug. Code:

local criminal1 = { "Criminal", "Street Rat", "0" } 
local criminal2 = { "Criminal", "Mugger", "100" } 
local criminal3 = { "Criminal", "Mobster", "200" } 
local criminal4 = { "Criminal", "Mercenary", "300" } 
local criminal5 = { "Criminal", "Kingpin", "500" } 
  
local police1 = { "Police", "Trainee", "0" } 
local police2 = { "Police", "Officer", "100" } 
local police3 = { "Police", "Head officer", "200" } 
local police4 = { "Police", "Marshall", "300" } 
local police5 = { "Police", "FBI Agent", "500" } 
  
--TEAM, OCCUPATION, RANKNAME, REQUIRED ACTIONS 
local civilian1 = { "Civilians", "Trucker", "Trucker Wannabe", "0" } 
local civilian2 = { "Civilians", "Trucker", "Rookietrucker", "50" } 
local civilian3 = { "Civilians", "Trucker", "Transport Tycoon", "75" } 
local civilian4 = { "Civilians", "Trucker", "Hauler", "100" } 
local civilian5 = { "Civilians", "Trucker", "King of the road", "150" } 
  
local emergency1 = { "Emergency", "Medic", "EMT", "0" } 
local emergency2 = { "Emergency", "Medic", "Nurse", "25" } 
local emergency3 = { "Emergency", "Medic", "Paramedic", "50" } 
local emergency4 = { "Emergency", "Medic", "Doctor", "75" } 
local emergency5 = { "Emergency", "Medic", "Surgeon", "100" } 
  
--outputChatBox ( criminal [ 1 ] ) -- bar 
--outputChatBox ( criminal [ 2 ] ) -- baz 
--outputChatBox ( criminal [ 3 ] ) -- anything 
  
function timer() 
setTimer(checkIfRankUp, "5000", 0) 
end 
  
function checkIfRankUp() 
local players = getElementsByType ( "player" ) 
for theKey,thePlayer in ipairs(players) do 
        if ( thePlayer ) then 
        if getElementData ( thePlayer, "Occupation" ) == "Criminal" then 
        criminal(thePlayer) 
        elseif getElementData ( thePlayer, "Occupation" ) == "Police" then 
                police(thePlayer) 
                elseif getElementData ( thePlayer, "Occupation" ) == "Trucker" then 
                trucker(thePlayer) 
                elseif getElementData ( thePlayer, "Occupation" ) == "Medic" then 
                medic(thePlayer) 
                 elseif getElementData ( thePlayer, "Occupation" ) == "Freeroam" then 
                 freeroam(thePlayer) 
                  elseif getElementData ( thePlayer, "Occupation" ) == "Unemployed" then 
                  unemployed(thePlayer) 
                else 
                return end 
                 
                end 
                end 
                end 
                 
                 
                function freeroam(thePlayer) 
                setElementData(thePlayer, "Occupation", "Freeroam") 
setElementData(thePlayer, "Rank", "Insane") 
                end 
  
                function unemployed(thePlayer) 
                setElementData(thePlayer, "Occupation", "Unemployed") 
                setElementData(thePlayer, "Rank", "Unemployed") 
                end 
  
                 
        function criminal(thePlayer) 
        local crimActions = getElementData(thePlayer, "Criminal-actions" ) 
        local occ = getElementData(thePlayer, "Occupation") 
        if crimActions >= 99 and crimActions <= 199 then 
        setElementData(thePlayer, "Rank", criminal2 [ 2 ] ) 
        elseif crimActions >= 199 and crimActions <= 299 then 
        setElementData(thePlayer, "Rank", criminal3 [ 2 ] ) 
        elseif crimActions >= 299 and crimActions <= 499 then 
        setElementData(thePlayer, "Rank", criminal4 [ 2 ] ) 
        elseif crimActions >= 499 and crimActions <= 900 then 
        setElementData(thePlayer, "Rank", criminal5 [ 2 ] ) 
        elseif crimActions == 0 then 
 setElementData(thePlayer, "Rank", criminal1 [ 2 ] ) 
 end 
 end 
  
 function police(thePlayer) 
        local polcActions = getElementData(thePlayer, "Police-actions" ) 
        local occ = getElementData(thePlayer, "Occupation") 
        if polcActions >= 99 and polcActions <= 199 then 
        setElementData(thePlayer, "Rank", police2 [ 2 ] ) 
        elseif polcActions >= 199 and polcActions <= 299 then 
        setElementData(thePlayer, "Rank", police3 [ 2 ] ) 
        elseif polcActions >= 299 and polcActions <= 499 then 
        setElementData(thePlayer, "Rank", police4 [ 2 ] ) 
        elseif polcActions  >= 499 and polcActions <= 900 then 
        setElementData(thePlayer, "Rank", police5 [ 2 ] ) 
        elseif polcActions == 0 then 
        setElementData(thePlayer, "Rank", police1 [ 2 ] ) 
        end 
        end 
         
        function trucker(thePlayer) 
        local trucActions = getElementData(thePlayer, "Trucker-actions" ) 
        local occ = getElementData(thePlayer, "Occupation") 
        if trucActions >= 0 and trucActions <= 49 then 
        setElementData(thePlayer, "Rank", civilian2 [ 3 ] )  
        elseif trucActions>= 49 and trucActions <= 74 then 
        setElementData(thePlayer, "Rank", civilian3 [ 3 ] ) 
        elseif trucActions >= 74 and trucActions <= 99 then 
        setElementData(thePlayer, "Rank", civilian4 [ 3 ] ) 
        elseif trucActions >= 99 and trucActions <= 149 then 
        setElementData(thePlayer, "Rank", civilian5 [ 3 ] ) 
        elseif trucActions == 0 then 
        setElementData(thePlayer, "Rank", civilian1 [ 3 ] ) 
        end 
        end 
         
        function medic(thePlayer) 
        local mediActions = getElementData(thePlayer, "Medic-actions" ) 
                local occ = getElementData(thePlayer, "Occupation") 
        if mediActions >= 0 and mediActions <= 24 then 
        setElementData(thePlayer, "Rank", emergency2 [ 3 ] ) 
        elseif mediActions>= 24 and mediActions <= 49 then 
        setElementData(thePlayer, "Rank", emergency3 [ 3 ] ) 
        elseif mediActions>= 49 and mediActions <= 74 then 
        setElementData(thePlayer, "Rank", emergency4 [ 3 ] ) 
        elseif mediActions >= 74 and mediActions <= 99 then 
        setElementData(thePlayer, "Rank", emergency5 [ 3 ] ) 
         elseif mediActions == 0 then 
        setElementData(thePlayer, "Rank", emergency1 [ 3 ] ) 
  
        end 
        end 
      addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), timer ) 
  

Link to comment

Look your self: The Bug Is I have this radio script and the problem is that when the player is in a vehicle, sometimes the radio stations gets removed automatically, fix this problem ty ! :D and i need a little help, so i can hear the music playing from another player's car when im outside of a vehicle

--FIX THIS PROBLEM TY.. So you cant say anything about me.

Im trying to do system what increasing your rank if you have required criminal-actions or medic, or trucker or police actions.

Link to comment

Lol, I said what was my problem on my post though :P Anyways, we don't want to cause a cat fight.

Anyways, you can check if the player has the amount of required criminal actions using this

if ( criminal2 [3] ) then 
setElementData(source,"Occupation", criminal2[2]) 

Link to comment

Okay. First of all, it took me a while to tabulate your code. Secondly, your 2nd argument in your timer included a string. It must be an integer.

  
local criminal1 = { "Criminal", "Street Rat", "0" } 
local criminal2 = { "Criminal", "Mugger", "100" } 
local criminal3 = { "Criminal", "Mobster", "200" } 
local criminal4 = { "Criminal", "Mercenary", "300" } 
local criminal5 = { "Criminal", "Kingpin", "500" } 
  
local police1 = { "Police", "Trainee", "0" } 
local police2 = { "Police", "Officer", "100" } 
local police3 = { "Police", "Head officer", "200" } 
local police4 = { "Police", "Marshall", "300" } 
local police5 = { "Police", "FBI Agent", "500" } 
  
--TEAM, OCCUPATION, RANKNAME, REQUIRED ACTIONS 
local civilian1 = { "Civilians", "Trucker", "Trucker Wannabe", "0" } 
local civilian2 = { "Civilians", "Trucker", "Rookietrucker", "50" } 
local civilian3 = { "Civilians", "Trucker", "Transport Tycoon", "75" } 
local civilian4 = { "Civilians", "Trucker", "Hauler", "100" } 
local civilian5 = { "Civilians", "Trucker", "King of the road", "150" } 
  
local emergency1 = { "Emergency", "Medic", "EMT", "0" } 
local emergency2 = { "Emergency", "Medic", "Nurse", "25" } 
local emergency3 = { "Emergency", "Medic", "Paramedic", "50" } 
local emergency4 = { "Emergency", "Medic", "Doctor", "75" } 
local emergency5 = { "Emergency", "Medic", "Surgeon", "100" } 
  
--outputChatBox ( criminal [ 1 ] ) -- bar 
--outputChatBox ( criminal [ 2 ] ) -- baz 
--outputChatBox ( criminal [ 3 ] ) -- anything 
  
function timer() 
    setTimer(checkIfRankUp, 5000, 0) 
end 
  
function checkIfRankUp() 
    local players = getElementsByType ( "player" ) 
    local method = "error" 
    local thePlayer = false 
    for i, v in ipairs(players) do 
        if ( v ) then 
            thePlayer = v 
            if getElementData ( thePlayer, "Occupation" ) == "Criminal" then 
                method = "criminal" 
            elseif getElementData ( thePlayer, "Occupation" ) == "Police" then 
                method = "police" 
            elseif getElementData ( thePlayer, "Occupation" ) == "Trucker" then 
                method = "trucker" 
            elseif getElementData ( thePlayer, "Occupation" ) == "Medic" then 
                method = "medic" 
            elseif getElementData ( thePlayer, "Occupation" ) == "Freeroam" then 
                method = "freeroam" 
            elseif getElementData ( thePlayer, "Occupation" ) == "Unemployed" then 
                method = "unemployed" 
            else 
                return 
            end 
        end 
    end 
                
                
    if method == "freeroam" then 
        setElementData(thePlayer, "Occupation", "Freeroam") 
        setElementData(thePlayer, "Rank", "Insane") 
    elseif method == "unemployed" then 
        setElementData(thePlayer, "Occupation", "Unemployed") 
        setElementData(thePlayer, "Rank", "Unemployed") 
    elseif method == "criminal" then 
        local crimActions = getElementData(thePlayer, "Criminal-actions" ) 
        local occ = getElementData(thePlayer, "Occupation") 
        if crimActions >= 99 and crimActions <= 199 then 
            setElementData(thePlayer, "Rank", criminal2 [ 2 ] ) 
        elseif crimActions >= 199 and crimActions <= 299 then 
            setElementData(thePlayer, "Rank", criminal3 [ 2 ] ) 
        elseif crimActions >= 299 and crimActions <= 499 then 
            setElementData(thePlayer, "Rank", criminal4 [ 2 ] ) 
        elseif crimActions >= 499 and crimActions <= 900 then 
            setElementData(thePlayer, "Rank", criminal5 [ 2 ] ) 
        elseif crimActions == 0 then 
            setElementData(thePlayer, "Rank", criminal1 [ 2 ] ) 
        end 
    elseif method == "police" then 
        local polcActions = getElementData(thePlayer, "Police-actions" ) 
        local occ = getElementData(thePlayer, "Occupation") 
        if polcActions >= 99 and polcActions <= 199 then 
            setElementData(thePlayer, "Rank", police2 [ 2 ] ) 
        elseif polcActions >= 199 and polcActions <= 299 then 
            setElementData(thePlayer, "Rank", police3 [ 2 ] ) 
        elseif polcActions >= 299 and polcActions <= 499 then 
            setElementData(thePlayer, "Rank", police4 [ 2 ] ) 
        elseif polcActions  >= 499 and polcActions <= 900 then 
            setElementData(thePlayer, "Rank", police5 [ 2 ] ) 
        elseif polcActions == 0 then 
            setElementData(thePlayer, "Rank", police1 [ 2 ] ) 
        end 
    elseif method == "trucker" then 
        local trucActions = getElementData(thePlayer, "Trucker-actions" ) 
        local occ = getElementData(thePlayer, "Occupation") 
        if trucActions >= 0 and trucActions <= 49 then 
            setElementData(thePlayer, "Rank", civilian2 [ 3 ] ) 
        elseif trucActions>= 49 and trucActions <= 74 then 
            setElementData(thePlayer, "Rank", civilian3 [ 3 ] ) 
        elseif trucActions >= 74 and trucActions <= 99 then 
            setElementData(thePlayer, "Rank", civilian4 [ 3 ] ) 
        elseif trucActions >= 99 and trucActions <= 149 then 
            setElementData(thePlayer, "Rank", civilian5 [ 3 ] ) 
        elseif trucActions == 0 then 
            setElementData(thePlayer, "Rank", civilian1 [ 3 ] ) 
        end 
    elseif method == "medic" then 
        local mediActions = getElementData(thePlayer, "Medic-actions" ) 
        local occ = getElementData(thePlayer, "Occupation") 
        if mediActions >= 0 and mediActions <= 24 then 
            setElementData(thePlayer, "Rank", emergency2 [ 3 ] ) 
        elseif mediActions>= 24 and mediActions <= 49 then 
            setElementData(thePlayer, "Rank", emergency3 [ 3 ] ) 
        elseif mediActions>= 49 and mediActions <= 74 then 
            setElementData(thePlayer, "Rank", emergency4 [ 3 ] ) 
        elseif mediActions >= 74 and mediActions <= 99 then 
            setElementData(thePlayer, "Rank", emergency5 [ 3 ] ) 
        elseif mediActions == 0 then 
            setElementData(thePlayer, "Rank", emergency1 [ 3 ] ) 
        end 
    end 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), timer ) 
  

Link to comment

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