Jump to content

I do have anoter question....


bartje01

Recommended Posts

Damn.

It doesn't work

At server side

  
function greetingHandler ( message ) 
  
  
end 
addEvent( "onGreeting", true ) 
addEventHandler( "onGreeting", getRootElement(), greetingHandler ) 
  

At client side

  
function greetingCommand ( sourcePlayer,cmd,who,amount ) 
    triggerServerEvent ( "onGreeting", getLocalPlayer(), "Hello World!" )  
if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then 
     account = getPlayerAccount(thePlayer) 
     local cash = getAccountData ( account, "data.cash" ) 
     local deaths = getAccountData ( account, "data.deaths" ) 
     local adminlevel = getAccountData ( account, "data.adminlevel" ) 
     outputChatBox ( "The client says: " .. message, source ) 
    outputChatBox ( "Money: ".. tostring( cash ) , thePlayer ) 
     outputChatBox ( "Deaths: ".. tostring( deaths ), thePlayer ) 
     outputChatBox ( "Adminlevel: ".. tostring( adminlevel ), thePlayer ) 
      
    end 
end 
  
addCommandHandler ( "greet", greetingCommand ) 
  

Link to comment

heres a part of my script:

client:

function swatCar() 
guiSetVisible(window, false) 
showCursor(false) 
triggerServerEvent( "spawnSWAT", getLocalPlayer(),getPlayerName( getLocalPlayer() ) ) 
end 

server:

addEvent("spawnSWAT", true)   
function carSwat(playerName) 
local guy = getPlayerFromName( playerName ); 
        local x, y, z = getElementPosition ( guy ) 
        local r = getPedRotation ( guy ) 
        vehicle = createVehicle ( 601, x, y, z, 0, 0, r ) 
        warpPedIntoVehicle ( guy, vehicle ) 
        outputChatBox("S.W.A.T spawned!", guy, 0, 255, 0) 
        end 
        addEventHandler ( "spawnSWAT", getRootElement(), carSwat ) 

Link to comment

erroors :o

serverside

  
function greetingHandler ( message ) 
account = getPlayerAccount(thePlayer) 
local cash = getElementData ( account, "data.cash" ) 
local deaths = getElementData ( account, "data.deaths" ) 
local adminlevel = getElementData ( account, "data.adminlevel" ) 
end 
addEvent( "onGreeting", true ) 
addEventHandler( "onGreeting", getRootElement(), greetingHandler ) 
  

clientside

  
function greetingCommand ( sourcePlayer,cmd,who,amount ) 
    triggerServerEvent ( "onGreeting", getLocalPlayer(), "Hello World!" )  
    account = getPlayerAccount(sourcePlayer) 
if not isGuestAccount ( getPlayerAccount ( sourcePlayer ) ) then 
      
     
      
    outputChatBox ( "Money: ".. tostring( cash ) , sourcePlayer ) 
     outputChatBox ( "Deaths: ".. tostring( deaths ), sourcePlayer ) 
     outputChatBox ( "Adminlevel: ".. tostring( adminlevel ), sourcePlayer ) 
      
    end 
end 
  
addCommandHandler ( "greet", greetingCommand ) 
  

  
[2011-03-09 16:39:03] WARNING: testmode\server.lua:146: Bad argument @ 'getPlayerAccount' 
[2011-03-09 16:39:03] WARNING: testmode\server.lua:147: Bad argument @ 'getElementData' 
[2011-03-09 16:39:03] WARNING: testmode\server.lua:148: Bad argument @ 'getElementData' 
[2011-03-09 16:39:03] WARNING: testmode\server.lua:149: Bad argument @ 'getElementData' 
  

Link to comment
Could you please fix it the right way?

There is nothing to fix in your's code - it is a random copying from the wiki.

One can only rewrite it using some logic... The goal is to "ask the server for accountData"

serverside

  
function greetingHandler ( ) 
  account = getPlayerAccount(source) 
  if not isGuestAccount (account ) then 
    local cash = getAccountData  ( account, "data.cash" ) 
    local deaths = getAccountData  ( account, "data.deaths" ) 
    local adminlevel = getAccountData  ( account, "data.adminlevel" ) 
    triggerClientEvent(source,"SendAccountData",source,cash,deaths,adminlevel) 
  end 
end 
addEvent( "onGreeting", true ) 
addEventHandler( "onGreeting", getRootElement(), greetingHandler ) 
  

clientside

  
function greetingCommand (  ) 
    triggerServerEvent ( "onGreeting", getLocalPlayer()) 
end 
addCommandHandler ( "greet", greetingCommand ) 
addEvent( "SendAccountData", true ) 
addEventHandler( "SendAccountData", getRootElement(), function(cash,deaths,adminlevel) 
    outputChatBox ( "Money: ".. tostring( cash ) ) 
     outputChatBox ( "Deaths: ".. tostring( deaths)  ) 
     outputChatBox ( "Adminlevel: ".. tostring( adminlevel ) ) 
end) 
  

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