Jump to content

_RuiGy

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by _RuiGy

  1. Oh, thank you! It's my first-week in lua, i'm still learning the syntax. ---------------------------------------------------------------- Btw, and is there a way to make a multidimensional table? Like: nItemFound[source][itemid] Thanks again!
  2. Hello again, I would like to know if there is a way to create player variables, example: --SERVER-SIDE local nItemFound = 0 --------------------- function onPlayerPickupItem( thePickup ) outputChatBox ( "* You found a item. Total itens found: " .. nItemFound, source ) nItemFound = nItemFound + 1 end addEventHandler ( "onPlayerPickupHit", getRootElement(), onPlayerPickupItem) But, this way when another player find a item nItemFound will be increased too. Thank you!
  3. Thank you, i changed my script to server-side. It works now.
  4. Hi, I am trying to make a script to save how much pizzas the player found. But i am getting some errors. This is my code: --server-side function onPlayerQuit() local playerAccount = getPlayerAccount(source) if (playerAccount) then for iii = 1, #nPizzaFound do setAccountData(playerAccount, "xtreme.pizza" .. iii, nPizzaFound[iii]) end end end addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit) function onPlayerLogin() local playerAccount = getPlayerAccount(source) if (playerAccount) then for iii = 1, #nPizzaFound do local playerPizzas = getAccountData(playerAccount, "xtreme.pizza" .. iii) if (playerPizzas) then nPizzaFound[iii] = playerPizzas end end end end addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin) nPizzaFound is definied in cliente-side --cliente-side local nPizzaPickup = { createPickup ( -1088.5999755859, 428.20001220703, 13.60000038147, 3, 1582 ), createPickup ( -1067.5, 407.20001220703, 13.60000038147, 3, 1582 ) } -------------------------------------------------------------------------------------- nPizzaFound = {} local nTotalFound = 0 --------------------- function createPizzaPickup ( ) outputChatBox ( "Find the pizzas!" ) end addEventHandler ( "onClientResourceStart", getResourceRootElement ( getThisResource ( ) ), createPizzaPickup ) -------------------------------------------------------------------------------------------------------------- function onPlayerPickupPizza ( thePickup ) for iii = 1, #nPizzaPickup do if thePickup == nPizzaPickup[iii] then if nPizzaFound[iii] == true then outputChatBox ( "You already found this pizza." ) return true end outputChatBox ( "You found the pizza " .. iii .. ". Here, have some money." ) givePlayerMoney ( 500 ) nPizzaFound[iii] = true nTotalFound = nTotalFound + 1 if nTotalFound == #nPizzaFound then outputChatBox ( "Congratulations! You found all pizzas. Here, have more money." ) givePlayerMoney ( 1500 ) end end end end addEventHandler ( "onClientPlayerPickupHit", localPlayer, onPlayerPickupPizza ) and this is the error i am facing: findPizzaMG_S.lua:5: attempt to get length of global 'nPizzaFound' (a nil value) Thanks for any help.
×
×
  • Create New...