Jump to content

Aibo

Retired Staff
  • Posts

    1,105
  • Joined

  • Last visited

Everything posted by Aibo

  1. it would be much easier for you if you'd have any idea about programming at all. this code is already a bit messy, you're just messing it up even more: addCommandHandler("roll", function(player,comd) local roll = math.random(1,4) if roll == 1 then outputChatBox("u won blablabla", player) -- no player was specified, message'd be shown to all elseif roll == 2 then outputChatBox("u lost blablabla", player) elseif roll == 3 then setPlayerMuted(player, true) -- as i recall, "source" is not passed by command handler, use "player", but i may be wrong setTimer(setPlayerMuted, 30000, 1, player, false) -- what's more, setTimer parameters were messed up, 30000 executions with 1ms interval. elseif roll == 4 then outputChatBox("u win blablabla", player) end end )
  2. price = {} price.nitro = 100 price.repair = 100 addCommandHandler("buy", function (player, command, item) if item == "nitro" then if getPlayerMoney(player) > price.nitro then local vehicle = getPedOccupiedVehicle(player) if vehicle then addVehicleUpgrade(vehicle, 1010) takePlayerMoney(player, price.nitro) outputChatBox("You've bought a nitro", player, 0, 222, 0, true) else outputChatBox("You are not in a vehicle", player, 222, 0, 0, true) end else outputChatBox("Not enough cash, nitro costs $"..price.nitro, player, 222, 0, 0, true) end elseif item == "repair" then if getPlayerMoney(player) > price.repair then local vehicle = getPedOccupiedVehicle(player) if vehicle then fixVehicle(vehicle) takePlayerMoney(player, price.repair) outputChatBox("You've bought a repair", player, 0, 222, 0, true) else outputChatBox("You are not in a vehicle", player, 222, 0, 0, true) end else outputChatBox("Not enough cash, repair costs $"..price.repair, player, 222, 0, 0, true) end end end ) something like that (not tested)
  3. Aibo

    Web request

    you're not even trying. dont you? and i bet JSON is the same everywhere. you need to (basically the stuff PHP SDK does with the input, except convertToObjects()): 1. get JSON from the input stream. in php: file_get_contents('php://input'); 2. decode JSON. in php: json_decode(file_get_contents('php://input')); and since you're making the page in ASP.NET you should know how to do this. and if you don't know, this has nothing to do with MTA or Lua scripting, so you should ask on relevant forums. *)
  4. Aibo

    Web request

    http://lmgtfy.com/?q=how+do+you+use+JSO ... ASP.NET%3F
  5. Aibo

    Web request

    there's no names, as i recall, it sends arguments as an ordered JSON array: https://forum.multitheftauto.com/viewtop ... 35#p303635
  6. ipairs is an iterator function, so brackets are needed: function Script_onResourceLoad ( resource ) if ( resource == getThisResource() ) then -- for each player already in the server for i, player in ipairs(getElementsByType ( "player" )) do -- you forgot the ipairs ( brackets ) -- binds the "i"-key to our function "modeIO" bindKey ( player, "i", "down", "modeIO" ) end end end addEventHandler ( "onResourceStart", getRootElement(), Script_onResourceLoad )
  7. maybe put the color grid in a single image, set it as "background", and put come corresponding radios (or small buttons) on top of every color? *)
  8. first help people to help you: 1. why you have two event handlers and two functions with the same name? 2. where's the part that calls function teleport(player)? 3. use [lua] tag instead of p.s.: hitPlayer in your teleport function isn't defined, cause i bet it's not a global var
  9. KIHC is a bit buggy and outdated (last update was 2008-05-24, if you haven't noticed). and there's no interior selection. it was discussed here: https://forum.multitheftauto.com/viewtop ... 91&t=26548 and here: https://forum.multitheftauto.com/viewtop ... 91&t=26537 you can get somewhat "fixed" by me KIHC (including disappearing house pickup) somewhere in those topics, but i'd still advice you to consider using some other house script.
  10. callClientFunction is just a custom function which calls client functions through event. if you have that added, then just call playSound from server for every player (near textDisplayAddObserver in your script) with needed file. server: if team1survivers > team2survivers then local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( redwinsdisplay, thisplayer ) callClientFunction(thisplayer, "playSound", "sounds/team1ftw.mp3") end local teampoints = getElementData ( team1, "Score" ) setElementData ( team1, "Score", teampoints+1 ) end if team2survivers > team1survivers then local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( bluewinsdisplay, thisplayer ) callClientFunction(thisplayer, "playSound", "sounds/ohnoes.mp3") end or you can use events: client: addEvent("playSomeSound", true) addEventHandler("playSomeSound", getRootElement(), playSound) server: if team1survivers > team2survivers then triggerClientEvent("playSomeSound", getRootElement(), "sounds/team1ftw.mp3") local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( redwinsdisplay, thisplayer ) end local teampoints = getElementData ( team1, "Score" ) setElementData ( team1, "Score", teampoints+1 ) end if team2survivers > team1survivers then triggerClientEvent("playSomeSound", getRootElement(), "sounds/ohnoes.mp3") local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( bluewinsdisplay, thisplayer ) end
  11. you mean this? function savePlayerLocation(player) local account = getPlayerAccount(player) local x, y, z = getElementPosition(player) local interior = getElementInterior(player) setAccountData(account, "savedX", x) setAccountData(account, "savedY", y) setAccountData(account, "savedZ", z) setAccountData(account, "savedInterior", interior) end
  12. Aibo

    set nick

    client part: -- this goes into your button click event: local playerName = guiGetText(yourGuiElementWithPlayerName) if playerName then triggerServerEvent("nameChangeRequest", getLocalPlayer(), playerName) else outputChatBox("Please enter the name") end server: addEvent("nameChangeRequest", true) addEventHandler("nameChangeRequest", getRootElement(), function(playerName) setPlayerName(source, playerName) end ) something like that. of course you can add some more checks like if newname == currentname or some unwanted symbols, well i can too, but i had no sleep for 20 hours
  13. Aibo

    set nick

    he means that this line should not be like this *) player events are sending player element as the source, so hitPlayer is not needed there: function playerLoginCheckSkin (thePreviousAccount, theCurrentAccount, autoLogin) local accountData = getAccountData (theCurrentAccount, "rpg-skins") if not accountData then setAccountData (theCurrentAccount, "rpg-skins", 15) triggerClientEvent (source, "showWin", getRootElement()) else triggerClientEvent (source, "dontShowWin", getRootElement()) end end addEventHandler ("onPlayerLogin", getRootElement(), playerLoginCheckSkin) (also, player you wish to trigger the event for must go in the first parameter of triggerClientEvent)
  14. Aibo

    Player Names

    http://www.lua.org/pil/2.html
  15. getElementsByType("player") *)
  16. http://www.lua.org/pil/4.3.2.html http://www.lua.org/pil/4.3.4.html http://www.lua.org/pil/4.3.5.html :3
  17. i bet that's server side script, while isElementOnScreen is obviously a client-only function.
  18. it's called a table, you create it somewhere with RegistroPaso = { } later you can set/get value from it with RegistroPaso['key'] = value, like: addCommandHandler("setvalue", function (player, command, value) if value then RegistroPaso[player] = value end end ) addCommandHandler("getvalue", function (player) if RegistroPaso[player] then outputChatBox("Your RegistroPaso value: " .. RegistroPaso[player], player) else outputChatBox("Your RegistroPaso value is not set", player) end end ) http://www.lua.org/pil/2.5.html
  19. outputChatBox("Du bist nicht der besitzer diese fahrzeugs!") you don't need player element here, since it's a client-side script:
  20. Aibo

    [Help] Marker's

    triggerServerEvent ( "RodytiLanga",getRootElement(),"Hello World!") triggerServerEvent is client-only function, and you use it in server-side script. *) if you want to trigger some event from server for particular player, use triggerClientEvent: triggerClientEvent ( hitElement, "RodytiLanga", getRootElement(), "Hello World!")
  21. well SQL functions obviously are server-side, since database is server-side you can also use setElementData (which is synchronized) to set vehicle owner when vehicle is spawned or bought by someone: setElementData(theVehicle, "vehicleowner", ownerName) and then you can access it client-side: if getElementData(theVehicle, "vehicleowner") == getPlayerName(player) then
  22. Aibo

    [Help] Marker's

    double check then, it works. though you probably better use "hitter", "hitElement" or some other variable instead of "source". because "source" is already sent and it's your marker element. this way you just discarding it by replacing with element that hit the marker. and you may need it later. even if you won't it can be confusing. (50p already discussed that somewhere in this forum) and you should place a check before outputChatBox, whether it's player element who hit the marker. function MarkerHit(hitElement, matchingDimension) if getElementType(hitElement) == "player" then outputChatBox("Text on marker", hitElement) end end addEventHandler( "onMarkerHit", JobMarker, MarkerHit ) anyway, it's all in the wiki
  23. there is already autoincrementing index "rowid", you don't need to create it. you can use it as you want, let it autoincrement itself or set your own value as with any other column, if you need to. and you can access by "rowid" name in your every table. and no, deleted IDs are not reused (until highest integer reached), autoincrementing goes from largest ID.
  24. in SQLite it's "INTEGER PRIMARY KEY" or "INTEGER PRIMARY KEY AUTOINCREMENT" actually, every table in SQLite already has autoincrementing index column called "rowid" (check in your SQL manager). and if you create another id column with "INTEGER PRIMARY KEY", it'll be just an alias of "rowid". http://www.sqlite.org/autoinc.html
×
×
  • Create New...