Jump to content

Help wins


Blinker.

Recommended Posts

hello guys , i need your help , i am stuck at Wins its not working and i don't know what's the problem ...

function Winsadd () 
    local Wins = getElementData(thePlayer,"Wins") 
    setElementData(thePlayer,"Wins",tonumber(getElementData(thePlayer,"Wins"))+1) 
end 
addEvent("onPlayerDestructionDerbyWin",true) 
addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),Winsadd) 

Thanks

Link to comment
function Winsadd () 
    local Wins = getElementData(thePlayer,"Wins") 
    local thePlayer = source 
    setElementData(thePlayer,"Wins",tonumber(getElementData(thePlayer,"Wins"))+1) 
end 
addEvent("onPlayerDestructionDerbyWin",true) 
addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),Winsadd) 
  

Still not working :/

Link to comment

line 2:

local Wins = getElementData(thePlayer,"Wins") -- you didnt use it and thePlayer isn't defined (its nil)

local thePlayer = source -- no need for that, just use source instead of thePlayer

anyway, You sure that the source is the player ?!

Is it Client or server side? and the event was triggered server-side or client-side? ?! i mean you typed :

"triggerEvent" or "triggerServerEvent" or "triggerClientEvent" ?!

Link to comment

this didn't work mate

look this is the whole script (its not mine) but this was for dm (wins not working , it was working onplayerwasted) i am trying to fix it for dd

gRoot = getRootElement() 
LastWinners={"","","","",""} 
  
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then  
            local playermoney = getPlayerMoney ( source )  
            local playerpoints = getElementData(source,"Points") 
            local playertime = getElementData(source,"Playtime") 
            local playerwins = getElementData(source,"Wins") 
            local playerdeaths = getElementData(source,"Deaths") 
            local playerhunters = getElementData(source,"Hunters") 
            setAccountData ( playeraccount, "money", playermoney ) 
            setAccountData ( playeraccount, "points", playerpoints ) 
            setAccountData ( playeraccount, "playtime", playertime ) 
            setAccountData ( playeraccount, "wins", playerwins ) 
            setAccountData ( playeraccount, "deaths", playerdeaths ) 
            setAccountData ( playeraccount, "hunters", playerhunters ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local playermoney = getAccountData ( playeraccount, "money" ) 
        local playerpoints = getAccountData ( playeraccount, "points" ) 
        local playertime = getAccountData ( playeraccount, "playtime" ) 
        local playerwins = getAccountData ( playeraccount, "wins" ) 
        local playerdeaths = getAccountData ( playeraccount, "deaths" ) 
        local playerhunters = getAccountData ( playeraccount, "hunters" ) 
        setPlayerMoney ( source, playermoney ) 
        setElementData(source,"Points",playerpoints or 0) 
        setElementData(source,"Playtime",playertime or 0) 
        setElementData(source,"Wins",playerwins or 0) 
        setElementData(source,"Deaths",playerdeaths or 0) 
        setElementData(source,"Hunters",playerhunters or 0) 
    end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) 
  
function BuyNos (player, command) 
    if (getPlayerMoney(player) > 10000) then 
        local auto = getPedOccupiedVehicle(player) 
        local nick = getPlayerName(player) 
        addVehicleUpgrade(auto,1010) 
        setPlayerMoney(player, getPlayerMoney(player) - 10000 ) 
        outputChatBox("#50B50D[sHOP] " .. nick .. " #50B50Dbought for #FFFFFF$10000 #50B50Dnitro!", getRootElement(), 255, 255, 255, true) 
        else  
        outputChatBox("#50B50DNot enough money.", player, 255, 255, 255, true) 
    end 
end  
addCommandHandler("nos", BuyNos) 
  
function BuyRepair (player, command) 
    if (getPlayerMoney(player) > 20000) then 
        local auto = getPedOccupiedVehicle(player) 
        local nick = getPlayerName(player) 
        fixVehicle(auto) 
        setPlayerMoney(player, getPlayerMoney(player) - 20000 ) 
        outputChatBox("#50B50D[sHOP] " .. nick .. " #50B50Dbought for #FFFFFF$20000 #50B50Drepair!", getRootElement(), 255, 255, 255, true) 
        else 
        outputChatBox("#50B50DNot enough money.", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("fix", BuyRepair) 
  
function BuyFlip (player, command) 
    if (getPlayerMoney(player) > 20000) then 
        local auto = getPedOccupiedVehicle(player) 
        local nick = getPlayerName(player) 
        rx, ry, rz = getVehicleRotation (auto) 
        setVehicleRotation (auto, rx +180, ry, rz +180) 
        setPlayerMoney(player, getPlayerMoney(player) - 20000 ) 
        outputChatBox("#50B50D[sHOP] " .. nick .. " #50B50Dbought for #FFFFFF$20000 #50B50Dflip!", getRootElement(), 255, 255, 255, true) 
        else 
        outputChatBox("#50B50DNot enough money.", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("flip", BuyFlip) 
  
addEventHandler ("onPlayerChat",getRootElement(), 
function(message,type) 
    local nick = getPlayerName(source) 
    if (string.find(message,"!points")) and not (string.find(message," !points")) then 
        local playerpoints = getElementData(source,"Points") 
        outputChatBox("#50B50D[POINTS] " .. nick .. " #50B50D has #FFFFFF" .. playerpoints .. "#50B50D points", getRootElement(), 255, 255, 255, true) 
    else if (string.find(message,"!cash")) and not (string.find(message," !cash")) then 
    outputChatBox("#50B50D[CASH] " .. nick .. " #50B50D has #FFFFFF" .. getPlayerMoney(source) .. "$#50B50D money ", getRootElement(), 255, 255, 255, true) 
    else if (string.find(message,"!playtime")) and not (string.find(message," !playtime")) then 
        local playertime = getElementData(source,"Playtime") 
        outputChatBox("#50B50D[PLAYTIME] " .. nick .. " #50B50D has played for #50B50D" .. playertime .. "#50B50D minutes", getRootElement(), 255, 255, 255, true) 
    else if (string.find(message,"!wins")) and not (string.find(message," !wins")) then 
        local playerwins = getElementData(source,"Wins") 
        outputChatBox("#50B50D[WINS] " .. nick .. " #50B50D has #FFFFFF" .. playerwins .. "#50B50D wins", getRootElement(), 255, 255, 255, true) 
    else if (string.find(message,"!deaths")) and not (string.find(message," !deaths")) then 
        local playerdeaths = getElementData(source,"Deaths") 
        outputChatBox("#50B50D[DEATHS] " .. nick .. " #50B50D has #FFFFFF" .. playerdeaths .. "#50B50D deaths", getRootElement(), 255, 255, 255, true) 
    else if (string.find(message,"!hunters")) and not (string.find(message," !hunters")) then 
        local playerhunters = getElementData(source,"Hunters") 
        outputChatBox("#191970* " .. nick .. " #8bbae9 has #FFFFFF" .. playerhunters .. "#8bbae9 hunters", getRootElement(), 255, 255, 255, true) 
    end 
    end 
    end 
    end 
    end 
end 
end) 
  
function updatePlayersStats ( ) 
    for index, player in ipairs ( getElementsByType "player" ) do  
    setElementData ( player, "Money", getPlayerMoney ( player ) ) 
    end 
end 
setTimer ( updatePlayersStats, 5000, 0 ) 
  
function UpdateMinute ( ) 
    for index, player in ipairs ( getElementsByType "player" ) do 
        setElementData(player,"Playtime",tonumber(getElementData(player,"Playtime"))+1) 
    end 
end 
setTimer ( UpdateMinute, 60000, 0 ) 
  
function checkForHunter(number,sort,model) 
    thePlayer = source 
    if sort == "vehiclechange" then 
        if model == 425 then 
            if getElementData(thePlayer,"playerGotHunter") == false then 
                setElementData(thePlayer,"playerGotHunter",true) 
                outputChatBox ( getPlayerName(source).." #FFFFFFgot #abcdef400 points #FFFFFFand #abcdef5000$ #FFFFFFhunter bonus!", getRootElement(), 255, 255, 255, true ) 
                setElementData(thePlayer,"Points",tonumber(getElementData(thePlayer,"Points"))+400) 
                givePlayerMoney(thePlayer,5000) 
                setElementData(thePlayer,"Hunters",tonumber(getElementData(thePlayer,"Hunters"))+1) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),checkForHunter) 
  
  
  
  
addEvent("onPlayerDestructionDerbyWin",true) 
addEventHandler("onPlayerDestructionDerbyWin", root, 
function ( ) 
 setElementData(source,"Wins",tonumber(getElementData(source,"Wins"))+1) 
    end 
 ) 
  
  
  

thanks

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