-
Posts
73 -
Joined
-
Last visited
Posts posted by Hadif
-
-
addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging", getRootElement(), function(newState, oldState) if (newState == "GridCountdown") then addEventHandler("onPlayerVehicleEnter", getRootElement(), setPlayerVehicle) -- don't add () end end ) function setPlayerVehicle(player) local vehicle = getPedOccupiedVehicle(player) if isPedInVehicle(player) then -- check if ped in vehicle if getElementModel(vehicle) then setElementModel(vehicle, 400) -- Test outputChatBox("setPlayerVehicle") end end end
idk but should work
Not working
-
I think this should work, but..
addEvent("onRaceStateChanging") addEventHandler("onRaceStateChanging", getRootElement(), function(newState, oldState) if (newState == "GridCountdown") then addEventHandler("onPlayerVehicleEnter", getRootElement(), setPlayerVehicle()) end end ) function setPlayerVehicle(player) local vehicle = getPedOccupiedVehicle(player) if getElementModel(vehicle) then setElementModel(vehicle, 400) -- Test outputChatBox("setPlayerVehicle") end end
I get an error,
11: Bad Argument @ 'getPedOccupiedVehicle' [expected ped at argument 1, got nil] 12: Bad Argument @ 'getElementModel' [expected element at argument 1, got boolean] 5: Bad Argument @ 'addEventHandler' [expected function at argument 3, got none]
-
startedResource is not defined in the handler. You need to add it as a parameter.
addEventHandler("onResourceStart", getRootElement(), function(startedResource)
No error but not working , I think I have to research how's race gamemode works.
-
addEvent('onMapStarting') addEventHandler('onMapStarting', root, function() for index, vehicle in pairs(getElementsByType('vehicle')) do setElementModel(vehicle, 411) end end)
Not working bro, I have made a new one but i got an error:
addEventHandler("onResourceStart", getRootElement(), function() setPlayerVehicle(startedResource) end ) function setPlayerVehicle(startedResource) -- gamemodes="race" type="map" local gamemodes = getResourceInfo(startedResource, "gamemodes") local types = getResourceInfo(startedResource, "type") if (gamemodes == "race") and (types == "map") then for index, vehicle in pairs(getElementsByType("vehicle")) do setElementModel(vehicle, 409) end end end
-
And XML is really bad for any server.
SQL is not that hard to learn. Check the tutorial in my signature.
Alright
-
Don't use XML for an account system, that's very inefficient and will probably cause lag and eat so much CPU. Use SQL or the default accounts system.
Im really bad in SQL.
-
Just the username or what...? Look up the XML writing functions on the MTA Wiki, there's plenty of information on how to read and write using those functions.
If you plan to store passwords as well, I suggest you do some research on password encryption. Storing password as plaintext is a terrible idea.
Then you simply store the account username in the XML file once they register an account. You'll need to write your own register function.
I'll try!
-
How do I save player account in XML file? I just want to manage the player account easily. How do I start? Any examples? Any help will be appreciate, thank you.
-
addEvent('onMapStarting') addEventHandler('onMapStarting', root, function() for index, vehicle in pairs(getElementsByType('vehicle')) do setElementModel(vehicle, 411) end end)
What a genius! Thank you so much, ill try it asap.
-
Hello, anyone knows how to replace vehicle model in race game-mode when the race map start? There's a event when the race game-mode map start called onMapStarting (source: https://wiki.multitheftauto.com/wiki/Resource:Race). So, how do I start?
-
Thanks, that example works but.. I have another problem, when I click and try to type, the character appears in both edit field. How do I solve this?
addEventHandler("onClientRender", getRootElement(), function() panelLogin() end ) local font = {"title", "subtitle", "display", "button"} ... font["display"] = dxCreateFont("file/ttf/roboto-regular.ttf", 9) ... local word = {"username", "password"} word["username"] = "" word["password"] = "" function panelLogin() ... local display = {} ... display[5] = dxDrawText(word["username"], 603, 366, 843, 382, tocolor(255, 255, 255, 255), 1.00, font["display"], "left", "center", false, false, false, false, false) display[6] = dxDrawText(word["password"], 603, 392, 843, 408, tocolor(255, 255, 255, 255), 1.00, font["display"], "left", "center", false, false, false, false, false) ... end function isMouseInPosition(absoluteX, absoluteY, screenW, screenH) if (not isCursorShowing()) then return false end local screenX, screenY = guiGetScreenSize() local cursorX, cursorY = getCursorPosition() local cursorX, cursorY = (cursorX * screenX), (cursorY * screenY) if (cursorX >= absoluteX and cursorX <= absoluteX + screenW) and (cursorY >= absoluteY and cursorY <= absoluteY + screenH) then return true else return false end end addEventHandler("onClientClick", getRootElement(), function() onClientClickEditPassword() onClientClickEditUsername() end ) function onClientClickEditUsername() if isMouseInPosition(603, 366, 240, 16) then addEventHandler("onClientCharacter", getRootElement(), onClientEditUsername) end end function onClientEditUsername(character) word["username"] = word["username"]..character end function onClientClickEditPassword() if isMouseInPosition(603, 366, 240, 16) then addEventHandler("onClientCharacter", getRootElement(), onClientEditPassword) end end function onClientEditPassword(character) word["password"] = word["password"]..character end
And by the way, how do I simplify the function? I think that my edit field will have a lot in my script and I don't want to repeat the script, there must be the way to make it own function, any help will be appreciate. Thank you for your time, may god bless your kindness and make you more genius!
-
addEventHandler ("onClientResourceStart", getRootElement(), function () local word = "" showCursor (true) end ) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing ( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function drawing () dxDrawRectangle (300, 300, 200, 100, tocolor (255, 255, 255)) dxDrawText (word, 310, 305, 200, 100, tocolor (255, 255, 255)) end addEventHandler ("onClientRender", getRootElement(), drawing) addEventHandler ("onClientClick", getRootElement(), function () if isMouseInPosition (300, 300, 200, 100) then outputChatBox ("You have clicked the rectangle, start writing") addEventHandler ("onClientCharacter", getRootElement(), writeInBox) end end ) function writeInBox (key) word = word .. key end
It is somehow like this
This example works without edit nothing?
-
Using guiGetText wouldn't really make a proper edit box. You can do it one this way, you declare an empty string, so you have to get mouse's position, if mouse is within the specified rectangle, and it clicks, then you start using onClientCharacter, which would look like this:
addEventHandler ("onClientCharacter", getRootElement(), function (key) yourstring = yourstring .. key end )
then draw the text with onclientrender, this is the way I do it
I guess this way is what I want, but... Can you explain more?
-
Hmhhh, how do I make my own? I don't want to includes the other resource. Any idea? By the way, thanks!
Perhaps you could download that resource, check the code and see how it works?
im not understand deutch language
-
function onDeleteCharacter() if editBoxState == true then textEdited = string.sub(textEdited,1,string.len(textEdited)-1) end end bindKey("backspace", "down", onDeleteCharacter) function onEditCharacter(character) if editBoxState == true then local count = string.len(textEdited) if count < 23 then textEdited = textEdited..character end end end addEventHandler("onClientCharacter", getRootElement(), onEditCharacter)
u just add to add ur variable textEdited on ur dxDrawText and make your click state (focus on edit box)
More explanation pls, it looks useful!
-
http://www.fileshare.ro/e31881719 There is the download link.
If you can repair the error you can send me a pm or write here where was the problem and what program you use to open files ? I want to know because i have a lot of skins and i want to have a model to fix them . Thanks in advance !
@Hadif I already do that . Thanks .
Welcome!
-
i think the problem is that dff/txd file is not a script, change it on meta.xml to file. eg: same as txd
-
Hmhhh, how do I make my own? I don't want to includes the other resource. Any idea? By the way, thanks!
-
How do I create edit box with DX?
-
You'll have to do it on your own. Use callRemote and PHP mail function.
Ok dude, thanks! Ill try..
-
Hello guys! How do I make a registration with an option to put Email?
-
local deathTimer function theLocator ( ) local allLocations = { "Las Venturas", "San Fierro", "Whetstone", "Flint County", "Red County", "Los Santos" } local allPlayers = getElementsByType ( "player" ) local allVehicles = getElementsByType ( "vehicle" ) for index, thePlayer in ipairs ( allPlayers ) do local theLocation = getElementZoneName ( thePlayer, true ) for index, allLocations in ipairs ( allLocations ) do if ( theLocation == allLocations ) then if not isTimer(deathTimer) then deathTimer = setTimer(killPed, 10000, 1, thePlayer ) end else if isTimer(deathTimer) then killTimer(deathTimer) end end end end for index, theVehicle in ipairs ( allVehicles ) do local theLocation = getElementZoneName ( theVehicle, true ) for index, allLocations in ipairs ( allLocations ) do if ( theLocation == allLocations ) then if not isTimer(deathTimer) then deathTimer = setTimer(blowVehicle, 10000, 1, theVehicle ) end else if isTimer(deathTimer) then killTimer(deathTimer) end end end end end
Not working...
-
Hello guys! I need to modify my script, I want to get times remaining. Example: If player get out from Tierra Robada and Bone County for 10 seconds, that player will be kill or vehicle will be explode. Any help will be appreciate!
Script:
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource ( ) ), function ( ) startLocator ( ) end ) function theLocator ( ) local allLocations = { "Las Venturas", "San Fierro", "Whetstone", "Flint County", "Red County", "Los Santos" } local allPlayers = getElementsByType ( "player" ) local allVehicles = getElementsByType ( "vehicle" ) for index, thePlayer in ipairs ( allPlayers ) do local theLocation = getElementZoneName ( thePlayer, true ) for index, allLocations in ipairs ( allLocations ) do if ( theLocation == allLocations ) then killPed ( thePlayer ) end end end for index, theVehicle in ipairs ( allVehicles ) do local theLocation = getElementZoneName ( theVehicle, true ) for index, allLocations in ipairs ( allLocations ) do if ( theLocation == allLocations ) then blowVehicle ( theVehicle ) end end end end function startLocator ( ) setTimer ( theLocator, 50, 0 ) end
-
source is not defined in setPlayerSpawn, you need to add it as an argument.
addEventHandler ( "onPlayerLogin", getRootElement ( ), function ( ) setPlayerSpawn (source ) end ) function setPlayerSpawn ( player ) setPlayerSpawnPosition ( player ) end function setPlayerSpawnPosition ( player ) local positions = { { -894.90002, 1963, 0.6, 14 }, { -893.40002, 1963.4, 60.6, 14 }, { -891.79999, 1963.8, 60.6, 14 } } local randomize = math.random ( 1, #positions ) spawnPlayer ( player, positions [ randomize ] [ 1 ], positions [ randomize ] [ 2 ], positions [ randomize ] [ 3 ], positions [ randomize ] [ 4 ] ) end
Are you sure? Ill try this later. Anyway, thanks for your help.
Question: engineLoadIFP/engineUnLoadIFP
in Scripting
Posted
When this function will be enable again? Im waiting it for a year. https://wiki.multitheftauto.com/wiki/EngineLoadIFP