Jump to content

Problems


Recommended Posts

Hai all , im here with 2 new problems o.0

Problem 1

Error :

[2012-03-03 14:27:30] ERROR: [scripts]/userpanelvcc/userpanel_s.lua:20: attempt to perform arithmetic on a nil value 
[2012-03-03 14:27:30] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:20: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] 
[2012-03-03 14:27:30] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:16: Bad argument @ 'isGuestAccount' [Expected account at argument 1, got boolean] 
[2012-03-03 14:27:30] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:15: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got number '0'] 

Lua code :

function DestructionWin( source ) 
local playersOnline = getPlayerCount() 
local rank1 = exports.race:getPlayerRank(source) or 1 
local firstMoney = tonumber(playersOnline)*20 or 1 
local secondMoney = tonumber(playersOnline)*10 or 1 
local thirdMoney = tonumber(playersOnline)*5 or 1 
local anotherMoney = tonumber(playersOnline)*2 
local rank = tonumber(rank1) 
local account = getPlayerAccount(source) 
    if isGuestAccount(account) then  
        outputChatBox ( "#FFA824 Dude , you need to log in to get the prizes.", source, 255,255,255,true ) 
        else 
        if rank == 1 then 
            setAccountData( account, "Race Wins", tonumber( getAccountData( account,"Race Wins" or 0 ) )+1 )   
            outputChatBox ( "#FFA824 CONGRATZ ! The player " .. getPlayerName( source ) .. " won "..tostring(firstMoney).." and 5 Points. !", root, 255, 255, 255, true )  
            setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + firstMoney ) 
            setAccountData( account,"Money", tonumber( getAccountData( account,"Points" ) or 0 ) + 5 ) 
        elseif rank == 2 then 
            setAccountData( account, "Race Loses", tonumber( getAccountData( account,"Race Loses" or 0 ) )+1 ) 
            outputChatBox ( "#FFA824 You lost. I wish you luck in the next round. Also you won "..tostring(secondMoney).." and 3 Points for being on the 2nd place.", source, 255, 255, 255, true )  
            setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + secondMoney ) 
            setAccountData( account,"Money", tonumber( getAccountData( account,"Points" ) or 0 ) + 3 ) 
        elseif rank == 3 then 
            setAccountData( account, "Race Loses", tonumber( getAccountData( account,"Race Loses" or 0 ) )+1 ) 
            outputChatBox ( "#FFA824 You lost. I wish you luck in the next round. Also you won "..tostring(thirdMoney).." and 1 Point for being on the 3th place.", source, 255, 255, 255, true )  
            setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + thirdMoney ) 
            setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + 1 ) 
        elseif rank >= 3 then 
            setAccountData( account, "Race Loses", tonumber( getAccountData( account,"Race Loses" or 0 ) )+1 ) 
            outputChatBox ( "#FFA824 You lost. I wish you luck in the next round. Sorry , no points for you , but you won "..tostring(anotherMoney).." for being on the "..tostring(rank).."th place.", source, 255, 255, 255, true )  
            setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + anotherMoney ) 
        end 
    end 
end 
addEventHandler( "onPlayerWasted",root,DestructionWin ) 

Dont copy or GRR !

Problem 2 :

Error :

[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:133: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:132: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:131: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:130: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:129: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:128: Bad argument @ 'setElementData' [Expected element at argument 1, got nil] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:126: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:125: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:124: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:123: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:111: Bad argument @ 'isGuestAccount' [Expected account at argument 1, got boolean] 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:110: Bad argument @ 'getPlayerSerial' 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:109: Access denied @ 'getClientIP' 
[2012-03-03 14:34:35] WARNING: [scripts]/userpanelvcc/userpanel_s.lua:108: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] 
[2012-03-03 14:34:35] ERROR: [scripts]/userpanelvcc/userpanel_s.lua:107: call: failed to call 'admin:getPlayerCountry' 
[2012-03-03 14:34:35] ERROR: [admin]/admin/server/admin_ip2c.lua:20: attempt to perform arithmetic on a boolean value 
[2012-03-03 14:34:35] WARNING: [admin]/admin/server/admin_ip2c.lua:20: Bad argument @ 'gettok' 
[2012-03-03 14:34:35] WARNING: [admin]/admin/server/admin_ip2c.lua:19: Bad argument @ 'gettok' 
[2012-03-03 14:34:35] WARNING: [admin]/admin/server/admin_ip2c.lua:15: Bad argument @ 'getPlayerIP' [Expected element at argument 1, got nil] 

Lua code :

function setData( source ) 
    local country = call( getResourceFromName( "admin" ), "getPlayerCountry", source ) 
    local account = getPlayerAccount( source ) 
    local ip =  getPlayerIP ( source )  
    local serial = getPlayerSerial ( source ) 
    if isGuestAccount( account ) then 
            outputChatBox( "#FFA824*You aren't logged in!", source, 255, 12, 15, true ) 
            setElementData ( source, "Ratio" , 0 ) 
            setElementData ( source, "Race Wins" , 0 ) 
            setElementData ( source, "Race Loses" , 0 ) 
            setElementData ( source, "Country" , country ) 
            setElementData ( source, "Points" , 0 ) 
            setElementData ( source, "Money" , 0 ) 
            setElementData ( source, "IP" , ip ) 
            setElementData ( source, "Serial" , serial ) 
            triggerClientEvent( source,"setText", source ) 
    else 
            local wins = getAccountData( account, "Race Wins" ) or 0 
            local money = getAccountData( account, "Money" ) or 0 
            local points = getAccountData( account, "Points" ) or 0 
            local loses = getAccountData( account, "Race Loses" ) or 0 
            local ratio = math.max( 0, math.min( 100, math.floor( wins / ( loses + wins ) * 100 ) ) ) or 0 
            setElementData ( source, "Ratio" , ratio ) 
            setElementData ( source, "Race Wins" , wins ) 
            setElementData ( source, "Race Loses" , loses ) 
            setElementData ( source, "Country" , country ) 
            setElementData ( source, "Points" , points ) 
            setElementData ( source, "Money" , money ) 
            triggerClientEvent( source,"setText",source ) 
    end  
end 
addEvent( "onPlayerShowWindow", true )  
addEventHandler( "onPlayerShowWindow", root, setData) 

Thank you for help.

Link to comment

For the problem 2 :

  
local state 
function showUserPanel ( ) 
    state = not state 
    showCursor ( not isCursorShowing( ) ) 
    guiSetVisible( userPanel,not guiGetVisible( userPanel ) ) 
    if state then 
        triggerServerEvent( "onPlayerShowWindow", localPlayer ) 
    end 
end  
bindKey( "F1", "down", showUserPanel ) 

From here is triggered , if someone needs it..

And in the first problem , i wanted to make a win system..

So : The last player who is alive , will get the specified number of money and 5 points

The player who died before him , will get the specified number of money and 3 points

And the player who died before the second one , will get the specified number of money and 1 point..

Link to comment
function setData( ) 
    local country = call( getResourceFromName( "admin" ), "getPlayerCountry", source ) 
    local account = getPlayerAccount( source ) 
    local ip =  getPlayerIP ( source ) 
    local serial = getPlayerSerial ( source ) 
    if isGuestAccount( account ) then 
        outputChatBox( "#FFA824*You aren't logged in!", source, 255, 12, 15, true ) 
        setElementData ( source, "Ratio" , 0 ) 
        setElementData ( source, "Race Wins" , 0 ) 
        setElementData ( source, "Race Loses" , 0 ) 
        setElementData ( source, "Country" , country ) 
        setElementData ( source, "Points" , 0 ) 
        setElementData ( source, "Money" , 0 ) 
        setElementData ( source, "IP" , ip ) 
        setElementData ( source, "Serial" , serial ) 
        triggerClientEvent( source,"setText", source ) 
    else 
        local wins = getAccountData( account, "Race Wins" ) or 0 
        local money = getAccountData( account, "Money" ) or 0 
        local points = getAccountData( account, "Points" ) or 0 
        local loses = getAccountData( account, "Race Loses" ) or 0 
        local ratio = math.max( 0, math.min( 100, math.floor( wins / ( loses + wins ) * 100 ) ) ) or 0 
        setElementData ( source, "Ratio" , ratio ) 
        setElementData ( source, "Race Wins" , wins ) 
        setElementData ( source, "Race Loses" , loses ) 
        setElementData ( source, "Country" , country ) 
        setElementData ( source, "Points" , points ) 
        setElementData ( source, "Money" , money ) 
        triggerClientEvent( source,"setText",source ) 
    end 
end 
addEvent( "onPlayerShowWindow", true ) 
addEventHandler( "onPlayerShowWindow", root, setData) 

Link to comment

This should work:

function DestructionWin( ) 
    local playersOnline = getPlayerCount() 
    local rank = tonumber(exports.race:getPlayerRank(source)) or 1 
    local firstMoney = tonumber(playersOnline)*20 or 1 
    local secondMoney = tonumber(playersOnline)*10 or 1 
    local thirdMoney = tonumber(playersOnline)*5 or 1 
    local anotherMoney = tonumber(playersOnline)*2 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then 
        outputChatBox ( "#FFA824 Dude , you need to log in to get the prizes.", source, 255,255,255,true ) 
    else 
    if (rank == 1) then 
        setAccountData( account, "Race Wins", tonumber( getAccountData( account,"Race Wins" or 0 ) )+1 )   
        outputChatBox ( "#FFA824 CONGRATZ ! The player " .. getPlayerName( source ) .. " won "..tostring(firstMoney).." and 5 Points. !", root, 255, 255, 255, true ) 
        setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + firstMoney ) 
        setAccountData( account,"Money", tonumber( getAccountData( account,"Points" ) or 0 ) + 5 ) 
    elseif (rank == 2) then 
        setAccountData( account, "Race Loses", tonumber( getAccountData( account,"Race Loses" or 0 ) )+1 ) 
        outputChatBox ( "#FFA824 You lost. I wish you luck in the next round. Also you won "..tostring(secondMoney).." and 3 Points for being on the 2nd place.", source, 255, 255, 255, true ) 
        setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + secondMoney ) 
        setAccountData( account,"Money", tonumber( getAccountData( account,"Points" ) or 0 ) + 3 ) 
    elseif (rank == 3) then 
        setAccountData( account, "Race Loses", tonumber( getAccountData( account,"Race Loses" or 0 ) )+1 ) 
        outputChatBox ( "#FFA824 You lost. I wish you luck in the next round. Also you won "..tostring(thirdMoney).." and 1 Point for being on the 3th place.", source, 255, 255, 255, true ) 
        setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + thirdMoney ) 
        setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + 1 ) 
    elseif (rank >= 3) then 
            setAccountData( account, "Race Loses", tonumber( getAccountData( account,"Race Loses" or 0 ) )+1 ) 
            outputChatBox ( "#FFA824 You lost. I wish you luck in the next round. Sorry , no points for you , but you won "..tostring(anotherMoney).." for being on the "..tostring(rank).."th place.", source, 255, 255, 255, true ) 
            setAccountData( account,"Money", tonumber( getAccountData( account,"Money" ) or 0 ) + anotherMoney ) 
        end 
    end 
end 
addEventHandler( "onPlayerWasted",root,DestructionWin ) 

Link to comment

Just 1 error :

  
ERROR: [scripts]/userpanelvcc/userpanel_s.lua:19: attempt to perform arithmetic on a nil value 

And on the another problem , doesn't give any errors , but it simply doesn't edits it..

Here is setText

  
addEventHandler("setText" , getRootElement() , 
function ( ) 
local ratio = getElementData ( source, "Ratio") or 0 
local wins = getElementData ( source, "Race Wins") or 0 
local loses = getElementData ( source, "Race Loses") or 0 
local country = getElementData ( source, "Country") or NA 
local points = getElementData ( source, "Points") or 0 
local money = getElementData ( source, "Money") or 0 
local ip = getElementData ( source, "ip") or NA 
local serial = getElementData ( source, "Serial") or NA 
guiSetText( label1, "Name : "..tostring(playerName).." .") 
guiSetText ( label2 , " Total Wins : "..tostring(wins).." .") 
guiSetText ( label3 , " Total Loses : "..tostring(loses).." .") 
guiSetText ( label4 , " Country : "..tostring(country)..".") 
guiSetText ( moneyLabel , " Money : "..tostring(money).." . ") 
guiSetText ( pointsLabel , " Points : "..tostring(points).." .") 
guiSetText ( label6 , " SERIAL : "..tostring(serial).." . ") 
guiSetText ( label7 , " IP : "..tostring(ip).." .") 
end) 
addEvent("setText" , true ) 
  

Edited by Guest
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...