Jump to content

Rank System


Agon

Recommended Posts

Posted
function setMyRank ( thePlayer, theKiller ) 
local account = getAccountName(getPlayerAccount( theKiller )) 
local money = getPlayerMoney( theKiller) 
    if isPedBot( thePlayer ) and if account and if not isGuestAccount then 
        givePlayerMoney( theKiller, 5) 
        setAccountData( myAccount, "theMoney", money) 
    end 
end 
addEventHandler ( "onPlayerDamage", getRootElement(), setMyRank ) 
  
function chatbox(text, msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
local myData = getAccountData( myAccount, "theMoney" ) 
if (msgtype == 0) then 
    if money > 50 then 
        outputChatBox("[Newbie]" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [Newbie] " .. name .. ": " .. text) 
        
    elseif money > 500 then 
     cancelEvent(true) 
        outputChatBox("[Amateur]" .. name ..":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [Amateur] " .. name .. ": " .. text) 
        
    elseif money > 5000 then 
     cancelEvent(true) 
        outputChatBox("[Pro]" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [Pro] " .. name .. ": " .. text) 
  
    else 
        outputChatBox("#FFFF00".. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: " .. name .. ": " .. text) 
        end 
  
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  

I made this but is there another way of doing this? because players can get money from stunting but i want them to get money from killing zombies.

Off Topic:

btw is there anything that saves skins, moneys, weapons in something like MySQL? because i have been home servering and i can't use MySQL. [You know some servers have MySQL when something happen to their server (like powercut), players' data won't get lost, but when i close my server, all players' data get lost]

Posted

for the off topic question you can save in the player account or in the sqlite. If you save in SQLite, the data will be stored in internal.db ( sorry if im not right, im not sure if its on registry.db or internal.db :lol: ).

For the code: First, isPedBot don't exists. Second, I think isGuestAccount need () after. Third, myAccount is nil :D. Fourth, If you use an statement, you don't need to use again in the same "line" like this:

if example() and account and not isGuestAccount() then 

Fifth, you can't use variable 'money' in another function because "money" it's a local variable, you can only use in setMyRank function.

Sixth, I don't know why you need to use cancelEvent() xD

Posted
function setMyRank ( theKiller ) 
    local account = getPlayerAccount(theKiller) 
    if (account and not isGuestAccount(account)) then 
        local money = getPlayerMoney(theKiller) 
        givePlayerMoney( theKiller, 5) 
        setAccountData( account, "theMoney", money) 
    end 
end 
addEvent("onZombieWasted",true) 
addEventHandler ( "onZombieWasted", getRootElement(), setMyRank ) 
  
function chatbox(text, msgtype) 
local name = getPlayerName(source) 
local money = getPlayerMoney(source) 
if (msgtype == 0) then 
    if money > 50 then 
        outputChatBox("[Newbie]" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [Newbie] " .. name .. ": " .. text) 
    elseif money > 500 then 
        cancelEvent(true) 
        outputChatBox("[Amateur]" .. name ..":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [Amateur] " .. name .. ": " .. text) 
    elseif money > 5000 then 
        cancelEvent(true) 
        outputChatBox("[Pro]" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: [Pro] " .. name .. ": " .. text) 
    else 
        outputChatBox("#FFFF00".. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: " .. name .. ": " .. text) 
    end 
elseif (msgtype == 2) then 
  
    end 
end 
addEventHandler("onPlayerChat", root, chatbox) 

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