Jump to content

Win trouble


Klesh

Recommended Posts

Posted

Hi comunity i have a script by me. but in scoreboard i set wins and this not works, here is the code

addEvent("onPlayerDestructionDerbyWin",true) 
addEventHandler("onPlayerDestructionDerbyWin",getRootElement(), 
function (winner) 
        outputChatBox(getPlayerName ( winner ) .. " is the last survivor and win 3 points getRootElement(),0,255,0) 
        setElementData(winner,"Points",tonumber(getElementData(winner,"Points"))+2) 
        setAccountData (account, "race-points", tonumber(2)) 
        setElementData(winner,"Wins",tonumber(getElementData(winner,"Wins"))+1) 
        setAccountData (account, "race-wins", tonumber(1)) 
else 
setAccountData (account, "race-points", tonumber(points + 2))       
end) 
  
addEventHandler("onPlayerWasted",getRootElement(), 
function () 
        setElementData(source,"Deaths",tonumber(getElementData(source,"Deaths"))+1) 
end) 
 

server - side

////////////////////////////////////

exports.scoreboard:addScoreboardColumn('Money') 
exports.scoreboard:addScoreboardColumn('Points') 
exports.scoreboard:addScoreboardColumn('Wins') 
exports.scoreboard:addScoreboardColumn('Achievements') 
function setstats () 
        local account = getPlayerAccount (source) 
    local money = getPlayerMoney ( source ) 
    setElementData ( source, "Money", "$" .. money ) 
    local points = getAccountData (account, "race-points" ) 
    if points == false then 
    setElementData ( source, "Points", "0" ) 
    else 
    setElementData ( source, "Points", points ) 
    end 
    local wins = getAccountData (account, "race-wins" ) 
    if wins == false then 
    setElementData ( source, "Wins", "0" ) 
    else 
    setElementData ( source, "Wins", Wins ) 
    end 
    local achive = getAccountData (account, "race-achive" ) 
    if achive == false then 
    setElementData ( source, "Achievements", "0" ) 
    else 
    setElementData ( source, "Achievements", achive ) 
    end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), setstats ) 
addEventHandler ( "onPlayerLogin", getRootElement(), setstats ) 
Help. 

What is wrong, why the wins not works, appears but not works.

Thanks for help

Posted

first script is client side? if yes then its totally wrong because account data is only server side.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

you said the second is client side, right? that means you are using server side functions / events on a client script, this won't work for sure, i recommend to learn from wiki and stop trying to create something without know anything.

https://wiki.multitheftauto.com/wiki/Scripting_Introduction

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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