Jump to content

bartje01

Members
  • Posts

    208
  • Joined

  • Last visited

Posts posted by bartje01

  1. Alright. I editted into a cmd. It doesn't work :(

      
    function setAdmin ( sourcePlayer,cmd,who,amount) 
        if ( not who and not amount ) then outputChatBox("*Use /makeadmin [Name] [level]", sourcePlayer, 180, 0, 0 ) return end 
        local gived = getPlayerFromName ( who ) 
        if not gived then outputChatBox("The player "..who.." is not connected", sourcePlayer, 180, 0, 0 ) return end 
        account = getPlayerAccount(gived) 
        if not isGuestAccount ( account ) then 
            local playerAdmin = getAccountData ( account, "data.adminlevel" ) 
             local success = setAccountData ( account, "data.adminlevel", tonumber(playerAdmin) ,tonumber(amount)) 
            if success then 
                outputChatBox ( "Your admin level has been setted.", gived ) 
                outputChatBox ( "You've setted his admin level.", sourcePlayer ) 
            else 
                outputChatBox("ERROR: His adminlevel his not setted", sourcePlayer, 180, 0, 0 ) 
            end 
        end 
    end 
    addCommandHandler ( "makeadmin", setAdmin ) 
      
    

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

  3. Hey again...I'm getting a bit crazy now. How can this be wrong?

      
    function onWasted (ammo, killer) 
         local account = getPlayerAccount(source) 
         local getPlayerDeaths = getAccountData(account, "data.deaths" ) 
         local getPlayerAdmin = getAccountData(account, "data.adminlevel" ) 
         if getPlayerDeaths then 
          local getPlayerCash = getAccountData(account, "data.cash" ) 
         setTimer( spawnPlayer, 2000, 1, source, 1187.19,-1324.01,13.55 ) 
         outputChatBox ( "You've paid 100$ for medical bill.", source ) 
         setAccountData ( account, "data.cash", tonumber(getPlayerCash) - 100 ) 
         setAccountData ( account, "data.deaths", tonumber(getPlayerDeaths) + 1 ) 
         setAccountData ( account, "data.adminlevel", tonumber(getPlayerAdmin) + 1 ) 
    else 
         setAccountData ( account, "data.deaths", 1 ) 
        end 
    end 
    addEventHandler ( "onPlayerWasted", root, onWasted ) 
      
    

    The cash goes -100. That's good

    The deaths goes + 1. That's good

    The adminlevel keeps saying: nil. wtf?

    I also got an error.

    I did all the same as with deaths. Then it should work or not?

      
    attempt to perform arithmetic on a nil value 
      
    

    Error line

      
     setAccountData ( account, "data.adminlevel", tonumber(getPlayerAdmin) + 1 ) 
      
    

  4. Hey guys. Another question once again.

    I want that I can see my stats in a GUI menu. But the GUI menu is created in client.lua

    And my stats in server.lua

    So how will I do that? It was an event function but I'm not sure how to use it.

    Please help.

  5. Lol ye thanks I failed damn bad xD I excidently copied and not removed the other cmds xD So I had them twice.

    Thanks for the help guys.

    Btw:

    I've made a NPC. But can someone send me a good wiki page of how I can make them walk around LS?

    I couldn't find it on wiki bad enough :(

  6. Hmm no errors anymore. /deaths works too

    but it doesn't work with my onplayerwasted

    Because of this I guess :$

    [code}
    [2011-03-07 23:07:55] ERROR: testmode\server.lua:84: attempt to perform arithmetic on a nil value
    [2011-03-07 23:07:55] ERROR: testmode\server.lua:114: attempt to perform arithmetic on local 'getPlayerCash' (a boolean value)
    [/code]

      
    function onWasted ( ) 
         local getPlayerDeaths = getElementData ( source, "data.deaths" ) 
          local getPlayerCash = getElementData ( source, "data.cash" ) 
         setTimer( spawnPlayer, 2000, 1, source, 1187.19,-1324.01,13.55 ) 
        outputChatBox ( "You've paid 100$ for medical bill.", source ) 
       setElementData ( source, "data.cash", getPlayerCash - 100 ) 
       setElementData ( source, "data.deaths", getPlayerDeaths + 1 ) 
    end 
    addEventHandler ( "onPlayerWasted", root, onWasted ) 
      
    

  7. Hey guys. I've learnt how to save money now.

    I tried the same with saving deaths. I failed

    For money everything works fine. But for deaths it doesn't work at all.

    What's wrong?

    This is the last thing I want to know for a while. after that I can help my self forward.

    Thanks MTa forum.

    I did it like this:

      
    function onLoginSetStats ( ) 
        if not isGuestAccount ( getPlayerAccount ( source ) ) then 
        account = getPlayerAccount(source) 
            if getAccountData ( account, "data.cash" ) then 
                givePlayerMoney(source, tonumber(getAccountData(account,"data.cash"))) 
                outputChatBox ( "Your stats are transfered back!", source ) 
            setAccountData(account,"data.deaths",tonumber(getAccountData(account,"data.deaths"))) 
            else 
             setAccountData( account, "data.cash", 0 ) 
             setAccountData( account, "data.deaths", 0 ) 
                outputChatBox ( "Your stats will now be saved." ) 
            end 
        end 
    end 
      
      
    function onLogoutSaveStats() 
    if not isGuestAccount ( getPlayerAccount ( source ) ) then 
        account = getPlayerAccount(source) 
        setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) 
        setAccountData( account, "data.deaths", 0 ) 
        setPlayerMoney(source,0) 
        end 
    end 
    addEventHandler ( "onPlayerLogout", root, onLogoutSaveStats ) 
      
    addEventHandler ( "onPlayerLogin", root, onLoginSetStats ) 
      
      
      
    function myStats ( thePlayer ) 
         if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then 
         account = getPlayerAccount(thePlayer) 
         local cash = getAccountData ( account, "data.cash" ) 
         local deaths = getAccountData ( account, "data.deaths" ) 
         outputChatBox ( "Stats: " .. tostring" Money: ".. ( cash ) , thePlayer ) 
        end 
    end 
    addCommandHandler ( "cash", myStats ) 
      
      
    function myStats2 ( thePlayer ) 
         if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then 
         account = getPlayerAccount(thePlayer) 
          
         local deaths = getAccountData ( account, "data.deaths" ) 
         outputChatBox ( "Stats2: " .. tostring" Deaths: ".. ( deaths ) , thePlayer ) 
        end 
    end 
    addCommandHandler ( "deaths", myStats2 ) 
      
    

    /deaths doesn't work

    ERROR: testmode\server.lua:72: attempt to concatenate local 'deaths' (a nil value)

  8. Nice. 2 warnings removed thanks

    2 left :(

    [2011-03-07 22:09:54] WARNING: testmode\server.lua:80: Bad argument @ 'getPlayerFromName'

    [2011-03-07 22:09:54] ERROR: testmode\server.lua:81: attempt to concatenate local 'who' (a nil value)

  9. Yay it works. But 3 warnings left when I type a wrong name. But it says player not connected though. SO it works

    it would be nice if we can fix these warnings

      
    [2011-03-07 21:26:52] WARNING: testmode\server.lua:82: Bad argument @ 'getPlayerAccount' 
    [2011-03-07 21:26:52] WARNING: testmode\server.lua:83: Bad argument @ 'isGuestAccount' 
    [2011-03-07 21:26:52] WARNING: testmode\server.lua:84: Bad argument @ 'getAccountData' 
    [2011-03-07 21:26:52] ERROR: testmode\server.lua:85: attempt to perform arithmetic on a nil value 
      
    

    That's weird

    Thankyou very much btw

  10. I use solidsnake's code now.

    It only works when I type a name that doesn't exists. Then it sets my money

    But when I try to do set someone his cash that's online it doesn't have effect again

    ERROR: testmode\server.lua:84: attempt to perform arithmetic on a nil value

  11. Still same warnings and errors

      
    [2011-03-07 16:08:13] WARNING: testmode\server.lua:70: Bad argument @ 'getPlayerAccount' 
    [2011-03-07 16:08:13] WARNING: testmode\server.lua:70: Bad argument @ 'isGuestAccount' 
    [2011-03-07 16:08:13] WARNING: testmode\server.lua:71: Bad argument @ 'getPlayerAccount' 
    [2011-03-07 16:08:13] WARNING: testmode\server.lua:72: Bad argument @ 'getAccountData' 
    [2011-03-07 16:08:13] ERROR: testmode\server.lua:73: attempt to perform arithmetic on a nil value 
      
    

  12. What I have:

      
    function myCash ( thePlayer ) 
         if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then 
         account = getPlayerAccount(thePlayer) 
         local cash = getAccountData ( account, "data.cash" ) 
         outputChatBox ( "Your cash is: " .. tostring ( cash ) .. " $ ", thePlayer ) 
        end 
    end 
    addCommandHandler ( "cash", myCash ) 
      
      
    function setCash ( sourcePlayer,givedname,amount) 
     local gived = getPlayerFromName ( givedname ) 
     if not isGuestAccount ( getPlayerAccount ( gived ) ) then 
     account = getPlayerAccount(gived) 
     local getPlayerCash = getAccountData ( account, "data.cash" ) 
     setAccountData ( account, "data.cash", tonumber(getPlayerCash) + tonumber(amount) or 100 ) 
     outputChatBox ( "Your cash has been setted.", gived ) 
     outputChatBox ( "You've setted his cash.", sourcePlayer ) 
        
       end 
    end 
    addCommandHandler ( "setcash", setCash ) 
      
    

    I also gave you another funtion

    It doesn't have effect ingame. But I have warning codes

      
      
    [2011-03-07 16:08:13] WARNING: testmode\server.lua:70: Bad argument @ 'getPlayerAccount' 
    [2011-03-07 16:08:13] WARNING: testmode\server.lua:70: Bad argument @ 'isGuestAccount' 
    [2011-03-07 16:08:13] WARNING: testmode\server.lua:71: Bad argument @ 'getPlayerAccount' 
    [2011-03-07 16:08:13] WARNING: testmode\server.lua:72: Bad argument @ 'getAccountData' 
    [2011-03-07 16:08:13] ERROR: testmode\server.lua:73: attempt to perform arithmetic on a nil value 
      
    

  13. Hey guys. I tried to make a /setcash cmd myself.

      
     function setCash ( sourcePlayer,givedname,amount) 
     local gived = getPlayerFromNick ( givedname ) 
      
     if not isGuestAccount ( getPlayerAccount ( gived ) ) then 
     local getPlayerCash = getAccountData ( account, "data.cash" ) 
     setAccountData ( account, "data.cash", tonumber(getPlayerCash) + 100 ) 
     outputChatBox ( "Your cash has been setted.", gived ) 
     outputChatBox ( "You've setted his cash.", sourcePlayer ) 
         
       end 
    end 
    addCommandHandler ( "setcash", setCash ) 
      
    

    I was already glad that I had no errors but it doesn't work at all. Just no reaction on my cmd.

    What is wrong?

    Thankyou

×
×
  • Create New...