Jump to content

Cronoss

Members
  • Posts

    173
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Cronoss

  1. Try this function playerChat(message, messageType) if messageType == 0 then --Global (main) chat local ID = getElementData(source, "ID") or "N/A" if isObjectInACLGroup("user."..getAccountName ( getPlayerAccount (source)), aclGetGroup ("Console") ) then outputChatBox("#DDA0DD* [#000000Fundador#DDA0DD] " ..getPlayerName(source).." ["..ID.."]: #FFFFFF"..message, root, 255, 0, 0, true ) outputServerLog("ChatLog: "..getPlayerName(source).." ["..ID.."]: "..message) elseif isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( source ) ), aclGetGroup ( "Adm" ) ) then outputChatBox("#DDA0DD* [#FF0000Administrador#DDA0DD] " ..getPlayerName(source).." ["..ID.."]: #FFFFFF"..message, root, 255, 0, 0, true ) outputServerLog("ChatLog: "..getPlayerName(source).." ["..ID.."]: "..message) elseif isObjectInACLGroup ("user."..conta, aclGetGroup ( "Everyone" ) ) then outputChatBox("#DDA0DD* [#9370DBPlayer#DDA0DD] " ..getPlayerName(source).." ["..ID.."]: #FFFFFF"..message, root, 255, 0, 0, true ) outputServerLog("ChatLog: "..getPlayerName(source).." ["..ID.."]: "..message) end end cancelEvent() --Change the cancel event to this part end addEventHandler("onPlayerChat", root, playerChat)
  2. Maybe adding this parameter? I had the same problem when I was testing some scripts in my server, this was the problem for me --server function j1server2() local x,y,z = 0, 0, 0 triggerClientEvent(source, "j1client",source, x,y,z) --This end addEvent("j1server2",true) addEventHandler("j1server2",root,j1server2) Also, I don't get why you add events to these functions if you are not gonna call them before with another function like "triggerServerEvent" or something like that, this should work exactly like you want: --server function j1server() local car1 = createVehicle (408, 0, 0, 0, 0, 0, 0, "car1", 0, 0, 0) j1server2() end addEvent("j1server",true) --------------------It is necessary here addEventHandler("j1server",root,j1server) function j1server2() local x,y,z = 0, 0, 0 triggerClientEvent("j1client",source, x,y,z) end addEventHandler("j1server2",root,j1server2) Another solution for me should be: --Client --Your 1st function blabla... function j1client0() triggerServerEvent("j1server",getLocalPlayer(), getLocalPlayer()) --Add this destroyElement(w1) showCursor(false) end --Server function j1server(player) local car1 = createVehicle (408, 0, 0, 0, 0, 0, 0, "car1", 0, 0, 0) --You could add the whole function j1server2, idk why you separate these functions triggerClientEvent(player, "j1client", player, x,y,z) end addEvent("j1server", true) addEventHandler("j1server",root,j1server)
  3. Could you show how you are calling those events? (server-side part)
  4. You can use these functions; onClientRender, dxDrawText, givePlayerMoney. <-- For the "countdown" https://wiki.multitheftauto.com/wiki/OnClientRender https://wiki.multitheftauto.com/wiki/DxDrawText https://wiki.multitheftauto.com/wiki/GivePlayerMoney But reading your post I think you are requesting for the full script, basically you want someone make it for you, and this is not the section you should post this
  5. The event is triggered once, inside the function "callCharacterCreation". This is where it is called: addEvent("selectionSlot", true) addEventHandler("selectionSlot", getRootElement(), function(player, selected, characterName, characterName2, characterName3) if selected == 1 then if characterName ~= "" then --If the character's name it's not empty then... --Removes the unnecesary element data local slot = 1 --Unnecesary callCharacterCreation(player, slot) --Triggers the function else --Removes the unnecesary element data end end --This function continues like that till the third slot --I noticed that I might use "selected" instead of creating a new variable called slot but I don't think that's the problem --And yes, I'm removing element data in every conditional part in the function because of; it's information that it's only necesary for the selection panel, after that, I don't need it
  6. --Server Side-- function callCharacterCreation(player, slot) setElementPosition(player, 209.75735473633,-33.699203491211,1001.9296875) setElementRotation(player, -0, 0, 137.15386962891) triggerClientEvent(source, "createCharacter", source, slot) end This is what the server-side trigger looks like. ^ I changed all the "getRootElement" to "root" but the problem it's still happening. This is what the error msg says: Version = 1.5.9-release-21210.0.000 Time = -- Module = D:\Multi Theft Auto\mta\multiplayer_sa.dll Code = 0xC0000005 Offset = 0x000026CB
  7. When my MTA crashes, a new window shows up and give me information about the crash (some codes like 0x0c005, i don't remember at all). There is no other function inside "createCharacterPanel", just dxDraw. And this doesn't happen randomly when the player enter into the "character creation", it only happens when the player reconnect
  8. Well, I've been trying to solve this problem time ago but nothing seems to work. When I was testing my new "login-system" I started to reconnect while the script was running and it crashed in the "Character creation", it always happen at that part, it never crashes at the login, register, or selection part, just when the player creates a character. I still can't figure out what it's causing this crash, basically all that part it's on Client-Side with dxDraw as panels I'm not even geting element data or something like this, take a look at the code: addEvent("createCharacter", true) addEventHandler("createCharacter", getRootElement(), function() setCameraMatrix(206.72476196289,-36.323947906494,1001.8046875, 209.75735473633,-33.699203491211,1001.9296875) addEventHandler("onClientRender", getRootElement(), createCharacterPanel) createCharacterButtons() end ) --The rest it's the panel, I removed it, and the problem it's still happening so...
  9. I made the full script and it works, thank you IIYama!
  10. I want to improve my skin system but I don't know really how to make the system select the first or second group of skins (male, and female). My original idea was get the "character gender", and that's what I want to do but I don't get how to make it possible. Any help would be appreciated local skins = { [1] = {1, 2, 7, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 43, 44, 45, 46, 47, 48, 49, 51, 52, 57, 58, 59, 60, 62, 66, 67, 68, 70, 72, 73, 78, 79, 80, 81, 82, 83, 84, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 132, 133, 134, 135, 136, 137, 142, 143, 144, 146, 147, 154, 155, 156, 158, 159, 160, 161, 163, 164, 165, 166, 167, 168, 170, 171, 173, 174, 175, 176, 177, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 200, 202, 203, 204, 206, 209, 210, 212, 213, 217, 220, 221,222, 223, 227, 228, 229, 230, 234, 235, 236, 239, 240, 241, 242, 247, 248, 249, 250, 252, 253, 254, 255, 258, 259, 261, 262, 264, 269, 270, 271, 272, 290, 291, 292, 293, 294, 295, 297, 299, 300, 301, 302, 303, 306, 307, 308, 310, 311, 312}, [2] = {9, 10, 11, 12, 13, 31, 38, 39, 40, 41, 53, 54, 55, 56, 63, 64, 69, 75, 76, 85, 87, 88, 89, 90, 91, 91, 93, 129, 130, 131, 138, 139, 140, 141, 145, 148, 150, 151, 152, 157, 169, 172, 178, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 201, 205, 207, 211, 214, 215, 216, 218, 219, 224, 225, 226, 231, 232, 233, 237, 238, 243, 244, 245, 246, 251, 256, 257, 263, 298, 304} }
  11. I'm searching for something that could allow the players to fly, not with a vehicle or something, I mean the player can enable it with a command and start flying. Is this possible with the MTA default commands? I tried with other commands but it only works if I'm in a vehicle
  12. I appreciate it, but this wouldn't cause lag problems if I ask for element data? something like this: function infoPanel() local name = getElementData(localPlayer, "character.2") --dx draw text blabla "your name: "..name.."" end addEventHandler("onClientRender", getRootElement(), infoPanel)
  13. I need help with something. I can't find anything about this on the forum, so I'll try to explain it; I want the player to be able to see their information in a panel (created with guieditor / dxDraw) Example: Your money: $40.000 Your Health: 100/100 I know this is possible but I don't know wich option I should choose for these "changing texts" : 1.- Using a "DX text" empty and then using some scripting, the player could get his info (?) 2.- Same here but with "label" (guieditor tool) (?) I'm not posting any code because I'm trying to figure out how to finish it, I just need to know between those options wich is the better way to make this possible
  14. I want to make a system like this but I don't know how to make it createPickup(blabla) -- This marks where the entry is createPickup(blabla) addEventHandler("onPlayerPickupHit", getRootElement(), function() cancelEvent() --prevents the pickups disappear end) -------------------This is the important part local pickups = { {"interior shop", 123,123,123,567,567,567}, {"interior hospital", 123,123,123,567,567}, } createMarker(blablabla) -- invisible marker in the same position of the pickups createMarker(blablabla) function teleportToInterior() local x,y,z = getElementPosition(source) -- i dont know how to make the system associates the player's position with the table data, if the position it's the same from the 3 first coordinates, then it will save that info and... teleportFunction(dataX, dataY,dataZ) --when the function recognizes where the player is, a function that teleport the player to the next coords is called
  15. If the player presses "shift" he can stop the animation and start moving, I want to freeze the player with that animation
  16. Doesn't work, the animation still can be interrupted
  17. In this case, I made the animation part in server-side so all the players can see the animation but for some reason the player can "cancel" the animation even if I set FALSE the interruptable part. What's the problem in this? setPedAnimation(source, "crack", "crckdeth1", -1, false, false, false, true) --should make it interruptable
  18. I want to make a "damage system", but I just realized that I'm triggering a serverEvent everytime the player """"dies"""", the event only contains setPedAnimation So... i don't know if this is necessary, I know I could make the same system on server side using "onPlayerDamage"(that way I'm not triggering an event just for animation), but i want to optimize this as much as i can. function playerWasted(attacker, damage) local health = getElementHealth(localPlayer) or 1 if health - damage <= 1 then if getElementData(localPlayer, "wasted.player") ~= 1 then cancelEvent() setElementData(localPlayer, "wasted.player", 1, false) setElementFrozen(localPlayer, true) triggerServerEvent("wastedEvent", localPlayer, localPlayer) -- necessary? -- The final question is; I should make the script again on server side, or keep it like this?(client-side) ^
  19. Thank you Burak, this worked @Citizen, the dxDrawText that I made it's not a field, it's text that helps the player to understand what he should type Example: "Password: [ ] " Thank you for the help too
  20. Now it's doesn't showing any text
  21. All my dxDraws works, the rectangle, the images, but the text in other's screens seems weird, why? I'm using "guiGetScreenSize". But I don't understand why this doesn't work with text Code: dxDrawText("Password", screenW * 0.4844, screenH * 0.5093, screenW * 0.5188, screenH * 0.5222, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) and... how Could I convert this memo position to fit all screens too? (I made all the elements relative but for some reason the gui elements kept with those numbers) It works, yeah, and the position doesn't change to much in another screen BUT if the resolution of the player is lower than mine, he can't see anything he is writting guiCreateMemo(0.45, 0.42, 0.10, 0.03, "", true)
  22. @Citizen I know this may be in another section but I see that you have experience and I don't want to create a whole topic for a single question; why setElementData and getElementData functions are so hated and not recommended in MTA Community? I understand that if I want to save "custom" data I should use SQL, but I would prefer this: function mySavedData(player, command, number, ...) if getElementData(player, "doIHaveCellphone")~=false then ---blablabla end end addCommandHandler("callsomeone", mySavedData) Instead this: function mySavedData(player, command, number, ...) local name = getPlayerName(player) local check = exports.mysql:_Query("SELECT cellphone FROM characters WHERE name=?", name) if (#check>0) then ---blablabla end end addCommandHandler("callsomeone", mySavedData) And... how do I know if I'm overusing the getelement and setelement functions? In my new fuel-system a lot of set element and get element has been created in the script, in first place I thought it shouldn't be like that but I think it's the only way a fuel system work properly
  23. 1.- and 2.- Solved and fixed that part, i didn't realize that vehicleEnter gives the seat number 3.- I changed that part before your answer, I thought it would be a bad idea because the server basically starts the timer and ends when the engine it's off, like, "start, cancel, start, cancel, start, cancel", but with your reply I'm confident about the logic of the script 4.- Got it 5.- I get it, but if i want to optimize this part I could use "removeElementData" inside "onVehicleStartExit" function ? I mean; I'm overwritting the timer everytime the player enters in a vehicle, and if he leaves the car... it is not neccesary to have that info saved in the server, right? I'm thinking about something like this: function removeFuelData(thePlayer, seat) if seat~=0 then return end if getVehicleEngineState(source)==false then if isTimer(timerF) then killTimer(timerF) end -------Don't know if this is neccesary if I set the timer as you said ('setElementData(source,"fuelTimer", timerF') removeElementData(source, "fuelTimer") end end addEventHandler("onVehicleStartExit", root, removeFuelData) I still don't know how to use properly the setTimer and killTimer functions but I'm trying to understand 6.- Got it
  24. Sorry for not answer this till now, solved, thank you @IIYAMA
  25. I made the code with the new logic and it works pretty good but the only problem it's that I only want to show the color when the vehicle engine it's ON, so deleting that part could be "weird" to see. (fuel "light" it's ON while the vehicle it's OFF?) anyway, I just want to know if "minor optimization" means that it doesn't matter too much or you are trying to say that it's nothing compared to the "triggerServerEvent" change. Also, I have a question about how to recognize if the player turns on the engine in this function... function setFuelCar(thePlayer) local source = getPedOccupiedVehicle(thePlayer) if getPedOccupiedVehicleSeat(thePlayer)==0 then if getVehicleEngineState(source)==true then ---------if the engine it's on I start the timer local x,y,z = getElementPosition(source) local fx,fy,fz = x+0.05, y+0.05,z+0.05 local fuelConsumption = 0.900 local fuelVeh = getElementData(source, "Fuel") or 0 if (fuelVeh <= 0) then setVehicleEngineState(source, false) else timerF = setTimer( function () local enginePlus = 0.200 local distance = getDistanceBetweenPoints3D(x,y,z,fx,fy,fz) local newFuel = tonumber((fuelVeh - (fuelConsumption*(distance+enginePlus)))) setElementData(source, "Fuel", newFuel) end, 20000, 0) end end end end addEventHandler("onVehicleEnter", root, setFuelCar) I modified the original script following your instructions and it's very different now, that's why I lost the possibility to check if the vehicle's engines it's on or off (AFTER the player enters) to start the timer, I don't know if there exist a command or handler like "onVehicleEngineChange" to check when the player turn on or turn off their car but i'm needing an alternative to this, no need code, just ideas of how to do it (if it is possible to make inside that function) also, thank you for your help, it's very appreciated
×
×
  • Create New...