Jump to content

Oscuro87

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by Oscuro87

  1. I'm not sure about the mechanics behind it (even though pretty much anything is possible i guess...) But I strongly support this idea. Cheers!
  2. Hmmm I just tried this, and again it triggers twice. It's bizarre 'cause logically, this should work nicely. Might aswell consider it's an MTA bug. Well if this remains like this, i can just say : if the total salary is == 0, then i don't trigger the server event or anything. It's really using duct tape, but whatever! EDIT: Or not... If i do the totalSalary trick, vehicle won't get deleted.
  3. Oh yes sure, First i separated both jobs into 2 distinct functions, i thought it was clearer that way. Here it is : function showSweeperGui(player) if player == localPlayer and getElementType(player) == "player" and not isPedInVehicle(player) then if getElementData(source, "markerJOB") == "streetsweeper" and not isPedInVehicle(player) then triggerServerEvent("onPlayerToggleMouse", localPlayer) guiSetVisible(gui,true) end end end addEventHandler("onClientMarkerHit", root, showSweeperGui) function stopSweeperJob(player) if player == localPlayer and getElementType(player) == "player" and isPedInVehicle(player) and getElementData(source, "markerJOB") == "streetsweeper" then local veh = getPedOccupiedVehicle(player) if getElementData(veh, "vehicleJOB") and getElementData(veh, "vehicleJOB") == "streetsweeper" then triggerServerEvent("onPlayerStopsStreetsweeperJob", player, totalSalary, veh) totalSalary = 0 killTimer(cleanerTimer) end end end addEventHandler("onClientMarkerHit", root, stopSweeperJob)
  4. Hey, thanks for the reply! I just tried your solution, and it fixes half of the problem indeed. Instead of triggering 4 times, it triggers twice, which is an improvement already. I just dunno why it still triggers 2 times as i blocked the "vehicle" element type. Kind of unsure on this one.
  5. Ohai I come today with a new oddity MTA came up with today. When any player is in a vehicle, and drives onto a marker, it triggers it not only once, but 4 times. Code might help, so : function showSweeperGuiOrStopJob() if getElementData(source, "markerJOB") == "streetsweeper" and not isPedInVehicle(localPlayer) then triggerServerEvent("onPlayerToggleMouse", localPlayer) guiSetVisible(gui,true) elseif isPedInVehicle(localPlayer) and getElementData(source, "markerJOB") == "streetsweeper" then local veh = getPedOccupiedVehicle(localPlayer) if getElementData(veh, "vehicleJOB") and getElementData(veh, "vehicleJOB") == "streetsweeper" then triggerServerEvent("onPlayerStopsStreetsweeperJob", localPlayer, totalSalary, veh) totalSalary = 0 killTimer(cleanerTimer) end end end addEventHandler("onClientMarkerHit", root, showSweeperGui) I'm basically using the same function to start the job (show the GUI) whenever a player steps on the marker while on foot. If the player is in a streetsweeper vehicle and drives through the marker, then it stops the job and pays him/her. That works, but it trigger the marker hit 4 times! Here's the chatbox output : And the warnings i get are that server cannot destroy element (of the car), nor kill the timer, which is normal as it's both been destroyed at the first "pass" of marker hit. How do I avoid my vehicle to trigger marker hit more than once? D: Thanks!
  6. Ahhh I see, so I was still doing it wrong. I should learn to read the wiki more thoroughly (or learn English idk...) Thanks a bunch Karthik_184!
  7. Hi, it's me again! (oh noes! ) Ok i'll briefly describe my problem : My world is loading twice when I use "onResourceStart" to setup all the stuff. Here is how I setup vehicles for example : function setupAllVehicles() [Here is the stuff to spawn vehicles, all that] end addEventHandler("onResourceStart", root, setupAllVehicles) I already checked several possibilities, including : me spawning the cars twice, but nope, I don't do that. IMPORTANT NOTE : This only happens when I first start the server (aka, when i double click on the MTA server icon to run it.) When i restart my resource ("restart oscuromode" in console), it DOES NOT load twice.
  8. Sorry for the late reply, i was off for a couple of days! Yes i know it returns an indexed table indeed, my question was more like : "Does this indexed table has a particular order? Like, is the nearest objects from the center of the colsphere at index 1 in the table? Or has the table a random order?" Sorry i wasn't clear! D: Thanks though!
  9. Hi! Just a quick question regarding getElementsWithinColShape: Does the table that results from this function have a particular order? Example : Assume there are at least 2 elements detected with the function getElementsWithinColShape(x,y), also assume that the colShape is a sphere, and is attached to the player. Would the resulting table's first element be the one that is the nearest to the player? Or would the first element of the table be the furthest element from the player? Or even, would the table's elements not have any particular order? (random?) Thanks in advance! (And don't hesitate to ask for precision, my English is far for quality!)
  10. Thanks to both of you who just pointed something important I was missing. Indeed, I personally thought that Mysql was actually more memory consuming than XML. But I see your point, especially when i see the function "xmlUnloadFile" (something like that), which means everything I do in XML is temporarily written in RAM memory... I should have noticed that earlier hehe.. So I guess i'm gonna go for mysql, as setting up a mysql database is easy as eating as sandwich. Thanks for the precisions!
  11. Hmmm I see your point, thanks for the enlightement! This thread is still open to people who want to add details/personal experience, btw.
  12. Yep, that's the idea. Tho I recently found out that if i want to use ID's when using xml files, i have to do a lot of manipulations on the file. For example, I store a lot of statically set coordinates in an XML file. Removing an entry in the middle of the file would create a hole in it, and, if un-managed, might also come to having duplicate ID's in the xml table. But at the same time, and as you said, MYSQL would be a bit big to just store static coordinates, but it has ID management. (kind of ) It also concerns me to use mysql too often, because in my mind it's a lot of extra overhead for the server. What you made me understand though is to limit the use of setElementData to only basic stuff, and not to store what's loaded from mysql, in a setElementData field. Oh and to make it clear, the initial question is basically "when to use, mysql, xml and setElementData". We answered two items there already. What about XML? When to use it?
  13. First of all, hi everyone! So today i come up with a new question : When should i pick mysql or xml, and for what type of job? I have in mind, speed of execution, but also i'm trying not to use a cannon to catch a fly. For now, I try not to use mysql for "lesser" jobs like storing static coordinates values i need to create markers. Then i use setElementData for storing what i load from MYSQL directly "in" the object. Of course i could be totally wrong in this method, as i might not be aware of performance issues caused by any of mysql/xml/setElementData methods. Could someone post how they're managing their data persistance? PS: This is, of course, not a thread about "omg mysql is better than xml", no. I'm just asking what method fits certain jobs the best. Thanks a bunch Oscuro
  14. Man!! I found the answer as i was fiddling around in my code. Then I thought like "if the clicks works with admin panel, then it must be using some kind of different click that i use or something". In fact, i was making the GUI CURSOR appear from the client side, aka with "guiSetInputEnabled" which is wrong! I had to make the cursor appear with the serversided function "showCursor".............. I told you it was retarded lol! This will teach me for mixing clientside and serverside... My basic idea was like : ok my gui and my click are client side, so my client will detect the ped and tell me what element it is. BUT NO! Ped is serversided! PFfffff Thanks all for your collaboration! Marked as resolved.
  15. Well of course, otherwise how could i click it?
  16. This gets me worried because nothing works, i can click on anything (world object or server created object) nothing works... Now i guess it's not from my side then? Thanks all for the help! EDIT : You know what? I'll try to rollback to the last NON-NIGHTLY build of MTA. What version are you guys using? And does "onClientClick" work for you? EDIT 2 : Wait wait, it worked there, but i had to have a GUI already opened somehow, but i saw a label "VEHICLE" written when i was clicking on a vehicle. But another GUI had to be opened or it didn't work. Also if i substitute the GUI label with outputChatBox it still doesn't work. Weirddd
  17. Hey I just tried your new attempt, and actually, no model at all is appearing in the chat box, altough i'm trying to click on the atm from a very close distance. It's like my click wasn't detected at all, it's really weird...
  18. Yep i'm totally sure i'm doing it right Sorry for the late answer, there was 8 hours sleep inbetween lol. Still investigating! EDIT : btw I tried with onElementClick too (which is a serversided event, correct me if i'm wrong), but it does exactly the same result : nothing. EDIT 2 : Someone told me about "debugscript 3", i'm gonna give it a shot see if there's something i'm missing. EDIT 3 : Nopes, no typo, nothing, not even a simple warning. Idk! EDIT 4 : What if i add a colshape around the ATM so it detects a collision, should that work? ALSO, i'm using nightly build from 3 days ago (23 may 2012), maybe the bug has been introduced then? EDIT 5 : I'll temporarly use markers as a solution, but i'd really like to find how to do this "onClientClick" thing, if anyone has a suggestion, you're more than welcome!
  19. Yep, i made sure i have only one ID for one atm, others ATMs are ID'ed differently, to avoid conflicts. @Jaysds1 : I just tried your version, but sadly it doesn't change the outcome, still trying to figure out, 'cause in my mind it makes sense. Thanks for trying though!
  20. Hey, thanks for stopping by! Indeed, i don't need to provide the 'target' for outputChatBox, when on clientside, as the target is the localplayer Though i'll still try to create my ATMs directly with createObject as you said, might be why it doesn't detect it!
  21. Hi , So like today i tried to use "onClientClick" clientside event to detect a click on an element (that is an ATM.) One thing you might want to know, is that the atm is actually created in the MAP EDITOR, which, i think, means it's created server-side, right? I used search in the wiki and on this forum for the past hour, and didn't come to anything concluding. I now rely on YOU! Here's my stuff : (CLIENT SIDE CODE) ---- Banking System (clientside) --[[ ATM IDs list LS_bank_ATM --]] local LS_BANK_ATM = getElementByID("LS_bank_ATM") setElementData(LS_BANK_ATM, "type", "atm") setElementData(LS_BANK_ATM, "name", "LS Bank ATM") function atmClicked(button, state, _,_, wx, wy, wz, element) if element and getElementData(element, "type") == "atm" and state == "down" then local x, y, z = getElementPosition(localPlayer) if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz) <= 10 then outputChatBox("DEBUGMSG::You clicked the atm.", 0,0,255) end end end addEventHandler("onClientClick", root, atmClicked) I took the code solidSnake14 kindly provides here on the forum, and modded it to my usage, but i can't make it work somehow. Thanks in advance
  22. Hmmm tricky, but i guess it could work! Thanks, i'll try right now and report back. SIDE NOTE: I tried a bit further fixing my problem, and it seems that when i use "getPedOccupiedVehicle()" it doesn't get it right away. It does like : 1) I spawn a car, then my clientside variable "vehicle" is still empty after "getPedOccupiedVehicle" 2) I spawn another car, then now "vehicle" contains THE FIRST vehicle. Heheh.. I don't know why! Still i will try your solution, it looks perfect. THANK YOU! PS: Dr. Who is awesome RESULT: As expected, it works! Thanks again!
  23. Hi! So, my client asks the server to spawn a car at a certain position (passed in parameter), and warps the spawning person into it. So far so good, but as it is called through an event (triggerServerEvent), how could I retrieve the instance of the car i just spawned? Sidenote : I tried to do a "getPedOccupiedVehicle(localPlayer)" right after the event is triggered, but the vehicle doesn't seem to be found, even if it exists. Here's a codebit to (maybe ) make it clearer : CLIENT SIDE : local posTab = { sx, sy, sz, srot } triggerServerEvent("requestVehicleSpawn", localPlayer, 448, posTab) local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle then outputChatBox("error retrieveing vehicel",255,0,0) end -- TO DEBUG The typoed message "error retrieving vehicle" is actually appearing, meaning the vehicle isn't found. SERVER SIDE EVENT HANDLER: ----- SPAWNS REQUESTED VEHICLE AT POSITION function spawnVehicle(modelid, position) local car = createVehicle(modelid, position[1], position[2], position[3], 0, 0, position[4]) warpPedIntoVehicle(source, car) end addEvent("requestVehicleSpawn", true) addEventHandler("requestVehicleSpawn", root, spawnVehicle) I'm probably doing something wrong (maybe even something obvious.. ), as it doesn't work! Forgive me, i'm new! Thanks in advance!
×
×
  • Create New...