Jump to content

Userpanel..again..xD


GanJaRuleZ

Recommended Posts

Ok , now im confused , idk how to solve these 2 errors :P

Problem 1

- client

function showUserPanel ( source ) 
if (guiGetVisible (userPanel)) then 
    guiSetVisible (userPanel, false) 
    showCursor (false) 
    triggerServerEvent("onPlayerShowWindow", getLocalPlayer() , source ) 
else 
    guiSetVisible(userPanel, true) 
    showCursor (true) 
    end 
    end 
bindKey ("F1", "down", showUserPanel) 

-server

  
addEventHandler("onPlayerShowWindow", getRootElement() , 
function ( source ) 
local country = call(getResourceFromName("admin"), "getPlayerCountry", source) 
local account = getPlayerAccount( source ) 
local askdname = getPlayerName( source ) 
local ip =  getPlayerIP ( source ) or NAN 
local serial = getPlayerSerial ( source ) or NAN 
if isGuestAccount( account ) then 
outputChatBox( "#FFA824*You aren't logged in!", thePlayer, 255, 12, 15, true) 
setElementData ( source, "Ratio" , NAN ) 
setElementData ( source, "Race Wins" , NAN ) 
setElementData ( source, "Race Loses" , NAN ) 
setElementData ( source, "Country" , country ) 
setElementData ( source, "Points" , NAN ) 
setElementData ( source, "Money" , NAN ) 
setElementData ( source, "IP" , ip ) 
setElementData ( source, "Serial" , serial ) 
triggerClientEvent("setText", getLocalPlayer() , 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 ) ) ) 
        if tostring( ratio ):find '-nan' then 
            ratio = 0 
        elseif tostring( ratio ):find 'inf' then 
            ratio = 0 
        end 
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 ) 
triggerServerEvent("setText", getLocalPlayer() , source ) 
end 
) 
addEvent("onPlayerShowWindow", true) 
  

Keeps saying

[2012-02-17 17:50:10] ERROR: Client triggered serverside event onPlayerShowWindow, but event is not added serverside 

Problem 2

Keeps saying

[2012-02-17 17:49:56] WARNING: Loading script failed: userpanelnew\server.lua:22: malformed number near '1stMoney' 

  
local playersOnline = getPlayerCount() 
local rank = getPlayerRank ( source ) 
local 1stMoney = playersOnline*20 or 1 
local 2ndMoney = playersOnline*10 or 1 
local 3rdMoney = playersOnline*5 or 1 
local anotherMoney = playersOnline * 2 

- here are the 6 lines -- the third line is the 22 one -- server side

Thank you in advance

Link to comment

1. proper indentation helps (see line 38):

addEventHandler("onPlayerShowWindow", getRootElement() , 
  function ( source ) 
    local country = call(getResourceFromName("admin"), "getPlayerCountry", source) 
    local account = getPlayerAccount( source ) 
    local askdname = getPlayerName( source ) 
    local ip =  getPlayerIP ( source ) or NAN 
    local serial = getPlayerSerial ( source ) or NAN 
    if isGuestAccount( account ) then 
      outputChatBox( "#FFA824*You aren't logged in!", thePlayer, 255, 12, 15, true) 
      setElementData ( source, "Ratio" , NAN ) 
      setElementData ( source, "Race Wins" , NAN ) 
      setElementData ( source, "Race Loses" , NAN ) 
      setElementData ( source, "Country" , country ) 
      setElementData ( source, "Points" , NAN ) 
      setElementData ( source, "Money" , NAN ) 
      setElementData ( source, "IP" , ip ) 
      setElementData ( source, "Serial" , serial ) 
      triggerClientEvent("setText", getLocalPlayer() , 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 ) ) ) 
      if tostring( ratio ):find '-nan' then 
        ratio = 0 
      elseif tostring( ratio ):find 'inf' then 
        ratio = 0 
      end 
      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 ) 
      triggerServerEvent("setText", getLocalPlayer() , source ) 
    end 
  -- missing end   
) 
addEvent("onPlayerShowWindow", true)  

also, getLocalPlayer() serverside? really?

2. variable names cannot start with a number.

Link to comment
1. proper indentation helps (see line 38):
addEventHandler("onPlayerShowWindow", getRootElement() , 
  function ( source ) 
    local country = call(getResourceFromName("admin"), "getPlayerCountry", source) 
    local account = getPlayerAccount( source ) 
    local askdname = getPlayerName( source ) 
    local ip =  getPlayerIP ( source ) or NAN 
    local serial = getPlayerSerial ( source ) or NAN 
    if isGuestAccount( account ) then 
      outputChatBox( "#FFA824*You aren't logged in!", thePlayer, 255, 12, 15, true) 
      setElementData ( source, "Ratio" , NAN ) 
      setElementData ( source, "Race Wins" , NAN ) 
      setElementData ( source, "Race Loses" , NAN ) 
      setElementData ( source, "Country" , country ) 
      setElementData ( source, "Points" , NAN ) 
      setElementData ( source, "Money" , NAN ) 
      setElementData ( source, "IP" , ip ) 
      setElementData ( source, "Serial" , serial ) 
      triggerClientEvent("setText", getLocalPlayer() , 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 ) ) ) 
      if tostring( ratio ):find '-nan' then 
        ratio = 0 
      elseif tostring( ratio ):find 'inf' then 
        ratio = 0 
      end 
      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 ) 
      triggerServerEvent("setText", getLocalPlayer() , source ) 
    end 
  -- missing end   
) 
addEvent("onPlayerShowWindow", true)  

also, getLocalPlayer() serverside? really?

2. variable names cannot start with a number.

I think he can use tonumber(playersOnline)

Link to comment

Server

addEvent( "onPlayerShowWindow", true )  
addEventHandler( "onPlayerShowWindow", root, 
    function ( ) 
        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 
) 

Client

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 ) 

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