Jump to content

tosfera

Members
  • Posts

    1,193
  • Joined

  • Last visited

Everything posted by tosfera

  1. Okee so, this sounds so easy and I've done it before, but I always did it client-sided. This time I'm trying to create a marker with a command ( /sell ), and the only simple thing Im trying right now, is saying a message when a player enters the marker. But somehow, the server sideded script isn't recognising the marker as a proper element... any idea's? addCommandHandler("sell", function ( source ) local x, y, z = getElementPosition ( source ) marker = createMarker(x, y, z-1, "cylinder", 4, 255, 0, 0, 150) end ) function testMarker( hitElement ) outputChatBox("You entered a marker!", source) end addEventHandler("onMarkerHit", getRootElement(), testMarker) I'm doing this server-sided because its going to be like; you want some support? enter this marker and a private message thingy comes up. Just for fun, its like... a trade on other games, but then just walking.
  2. tosfera

    Mechanic

    Just what Solid said: change local driver = getVehicleOccupant (player) to local driver = getVehicleOccupant(car)
  3. Thanks Solid and 50p for clearing it up; An element in not being attached tot he forklift when you're trying to pick it up. Time to write my other idea now :3
  4. tosfera

    Saving number

    Okee first thing I see that isn't right(in my eye's) is: local account = getPlayerAccount( root ) normally thats handeled like; local account = getPlayerAccount(source) but since you want to save the user that quits; server: function saveAll( number ) local account = getPlayerAccount( player ) if ( account ) then triggerClientEvent(player, "count", root) setAccountData( account, "number", number) end end addEventHandler( "onPlayerQuit", getRootElement(), saveAll ) function giveAll() local account = getPlayerAccount( player ) if ( account ) then getAccountData( account, "number") end end addEventHandler( "onPlayerLogin", getRootElement(), giveAll() ) client: number = 0 addEvent("count", true) addEventHandler("count", getLocalPlayer(), setTimer( function() number = number + 1 triggerServerEvent("saveAll",getLocalPlayer(),number) end, 60000, 0 ) ) See if it works (haven't tested it)
  5. Would be awesome, I do have an idea how to fix it in another way, but that isn't rly realistic.
  6. Wonder wat 50p or SolidSnake has to say about this...
  7. Thats the point, is an object getting attached to a forklift if you try to lift it?
  8. tosfera

    tonumber?

    to can use tostring for money, like; local loan = givePlayerMoney(hitPlayer, money) -- money = an int triggerClientEvent(source, "errorMsg", root, "Well done! I'll give you: $".. tostring(money)) -- now its a string tonumber (source: wiki) function displayVehicleLoss(loss) local thePlayer = getVehicleOccupant(source) if(thePlayer) then -- Check there is a player in the vehicle outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " health.", thePlayer) -- Display the message end end addEventHandler("onVehicleDamage", getRootElement(), displayVehicleLoss)
  9. wiki: "This function is provided by the external module MTA-MySQL. You must install this module to use this function." have you done it? (https://wiki.multitheftauto.com/wiki/Mod ... ql_connect) also, if you dont want to install the module, use this: dbConnect
  10. tosfera

    tonumber?

    Think about this; I'm and vehicle and my fuel is placed into userdata, wich is a string. You want to use the ammount of fuel that has been used in that day, well use tonumber to do so.
  11. Keep getting the message;"You need to pickup the supplies first!" addEventHandler("onClientMarkerLeave", root, function ( hitElement ) local v = getPedOccupiedVehicle ( hitElement ) local element = getElementAttachedTo ( v ) local object = getAttachedElements ( element ) if object then outputChatBox("ok!") else outputChatBox("You need to pickup the supplies first!") end end ) results I got back: local v = userdata local element = false local object = false
  12. tosfera

    cutscenes?

    option 1: Create a new dimension (keep checking if it isn't used), let players walk in it, and drive and stuff. option 2: Let them see a video in game.
  13. woow, please punch me in the face. Going to try it, thanks!
  14. HEy, I was asking myself, can you get an attached object? Like, I'll create a marker @ 0,0,0 (position) and a box at 5, 5, 5. I'll use a forklift to grab and lift the box, and when I hit the marker it has to say like; good job! you are holding the object: . I've no idea if that is possible, if it is. Does anyone have a idea how to check it?
  15. np, its cool to see people their interest in LUA and MTA.
  16. I've been like you, scripting my ass of on stuff I didn't know. But when you find the wiki (https://wiki.multitheftauto.com/wiki/Main_Page), things will get easy. Just put some keywords in and test the function out. To help you out in the first part right here, I'll give you a quick and nice code: To spawn the player when he dies, the eventHandler "onPlayerWasted" will be called: addEventHandler("onPlayerWasted", root, function ( source ) spawnPlayer( source, 1176.2972412109, -1323.7965087891, 14.014363288879 ) fadeCamera ( source, true ) setCameraTarget ( source, source ) end ) This is actually quite,,, stupid if you ask me. You'll die and respawn immediately. Now up to you to create a timer that will respawn the player. tip: setTimer
  17. Too hard for my brain if learning lua is to hard for your brain, start at the highest point and jump down! With saying that I mean, you want to learn lua and also make something usefull for your self, so... Create a script that saves the user information into a database, just keep it simple first. Save the serial of an user in a table, you can use the function dbConnect and executeSQLQuery for that. First thing to do is create a dbconnection dbConnect( "sqlite", "file.db" ) -- string databaseType, string host after you got the connection to your database, you can start selecting and inserting stuff. Before you can do this, you need to have alitle knowledge about SQL. but the functions you're going to use are; create table insert select to help you into the right direction: local dbType = "sqlite" local dbFile = "mtaServer.db" addEventHandler("onResourceStart", root, function () local create = executeSQLQuery("CREATE TABLE IF NOT EXISTS `players` (`serial` TEXT)") if ( create ) then outputChatBox("Table created!") end end ) addCommandHandler("saveSerial", function ( source ) local serial = getPlayerSerial( source ) local insert = executeSQLQuery("INSERT INTO players(serial) VALUES(?)", serial ) if ( insert ) then outputChatBox("Serial saved into the db!") end end ) (haven't tested it)
  18. With this setup, I've created a command you might like too; addEventHandler("onPlayerCommand", root, function(cmd) if cmd == "votemap" then local accName = getAccountName ( getPlayerAccount ( source ) ) -- get his account name if not isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) -- if he isn't an admin outputChatBox ( "INFO: Comand votemap is disabled for normal players, please ask and admin to start a vote.", source, 255, 69, 0 ) cancelEvent() end end end)
  19. Well, to create a faction-system like valhalla had/has (dont know if the server is still around). You have to know 2 things; Lua and SQL. Without lua, you can do it, but it will be hard. Without SQL knowledge,,, you can better stop right away. The errors will kill you. If you got them both, alitle knowledge is enough. First off all you need to create a gui, this gui will get information from the db like you request. Make a start with creating a db and just try to get a "Hello World" out of it when you type in a command like; "testdb". You'll need these functions: dbConnect executeSQLQuery
  20. @Alhajarii, this will be a client side script for sure. Else everyone will see flying players! To start off, we will need the following functions (correct me if I'm wrong, I haven't written it so I'm just thinking right now): createPed (use the client function for it!) guiCreateButton setElementModel getElementModel spawnPlayer (server side) Okee, I'm not writing the script for you, but I'll make an overview to see how the script is going to work; - player logs in - player will get the buttons and the standart skin (0) - player will choose the skin with the buttons - player presses the button - player will get spawned with the selected skin (ElementModel) Goodluck! tell me if you're stuck.
  21. Thanks! You're like,,, god or something. back in the days when we still talked, you were good. But now, FCK ITS INSANE!
  22. @devildead622, if you're stuck. I made the script for you. so if you rly can't find it out, I can give you a part so you can continue with it.
  23. Hmm,, since you're still here. It doesn't destroy the element after 3 times. O_O, like, I'm becoming a trucker, doing 3 runs, and the third time, the markers doens't get destroyed. but I am getting an error, dont know if thats the problem. Bad 'ped' pointer @ getPedOccupiedVehicle He's crying about this part; (server scripts btw) addEventHandler("onMarkerHit", jobMarker_trucker_newTrailer, function ( hitPlayer, source ) local v = getPedOccupiedVehicle( hitPlayer ) if v then local model = getElementModel(v) if model == 515 then if job then triggerClientEvent(hitPlayer, "errorMsg", root, "You still got a delivery to do!") else triggerClientEvent(hitPlayer, "errorMsg", root, "Great work, keep it up!") triggerClientEvent(hitPlayer, "startJob_trucker", root) end end end end )
×
×
  • Create New...