
myonlake
Members-
Posts
2,312 -
Joined
-
Days Won
41
Everything posted by myonlake
-
Yes but getPedOccupiedVehicle() would not work if it wasn't a car, it would just output an error if he's not in a car. getPedOccupiedVehicle fetches the current VEHICLE so getElementType is unneeded
-
Yeah but you checked it it's a vehicle, you can just remove the getElementType and leave isElement there Or then just leave: if vehicle then Because it checks if the player is in a vehicle at the time the function is to be executed.
-
getPedOccupiedVehicle() is automaticly a vehicle element, you're making a check if the occupiedVehicle is a vehicle element, which is unnecessary, also, trigger arguments are not recommend, so that's why you are able to make occupiedVehicle server-side. And no problem, we kind of have the same script.
-
GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(417, 300, 467, 219, "destroy", false) GUIEditor_Button[1] = guiCreateButton(37, 119, 148, 54, "destroy", false, GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(268, 117, 148, 54, "x", false, GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1], false) addEventHandler("onClientGUIClick", root, function(button, state, absoluteX, absoluteY) if (source == GUIEditor_Button[2]) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) guiSetInputEnabled(false) end end, false ) addEventHandler("onClientGUIClick", root, function(button, state, absoluteX, absoluteY) if (source == GUIEditor_Button[1]) then triggerServerEvent("destroy", localPlayer) end end, false ) addEvent("destroy",true) addEventHandler("destroy", root, function() local vehicle = getPedOccupiedVehicle(source) if vehicle and destroyElement(vehicle) then local cash = math.random(15461, 34641) givePlayerMoney(source, cash) outputChatBox("* Destroyed your vehicle for $" .. cash, source, 255, 0, 0) else outputChatBox("* Enter a vehicle first.", source, 255, 0, 0) end end )
-
Let's try X-SHADOW's code then, but at least my Role Play script works without adding it to the arguments of function. addEvent("infosend", true) addEventHandler("infosend", root, function(accName, atype, pname) aname = guiCreateLabel(11, 745, 96, 18, tostring(accName), false) admtype = guiCreateLabel(135, 745, 96, 18, tostring(atype), false) nick = guiCreateLabel(280, 745, 96, 18, tostring(pname), false) end ) addEventHandler("onClientRender", root, function() triggerServerEvent(source, "checkinfo", source) end ) addEvent("checkinfo", true) addEventHandler("checkinfo", root, function(source) local acc = getPlayerAccount(source) local accName = getAccountName(acc) if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then atype = "Admin" pname = getPlayerName(source) triggerClientEvent(source, "infosend", source, accName, atype, pname) end end )
-
triggerClientEvent("infosend", source, accName, atype, pname) After the event name, there's a 'source' defined. The source is basically the thing you do not need to replay in the following code. function stuff(source) Source is not needed there, because it is already defined in the trigger.
-
X-SHADOW, your code is wrong. There's no need for "thePlayer", and the clientTrigger is just fine, though I made few fixes to unnecessary parts. Server addEvent("checkinfo", true) addEventHandler("checkinfo", root, function() local acc = getPlayerAccount(source) local accName = getAccountName(acc) if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then atype = "Admin" pname = getPlayerName(source) triggerClientEvent(source, "infosend", source, accName, atype, pname) end end ) Client addEvent("infosend", true) addEventHandler("infosend", root, function(accName, atype, pname) aname = guiCreateLabel(11, 745, 96, 18, tostring(accName), false) admtype = guiCreateLabel(135, 745, 96, 18, tostring(atype), false) nick = guiCreateLabel(280, 745, 96, 18, tostring(pname), false) end ) addEventHandler("onClientRender", root, function() triggerServerEvent("checkinfo", source) end )
-
I am currently making one for my own game mode (Basic Role Play). Feel free to contact me for further details via PM.
-
Believe me, element datas are working well. I will take a look if I have disabled collisions.
-
You need to go away from the position. And you also need to delete the LOD object.
-
Hello, So, I am trying to make a GUI that pops open when a player clicks a dead pedestrian (which is a character killed player), but it seems my debug outputs say it's not an element, how come? local screenx, screeny = guiGetScreenSize() addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if button == "left" and state == "up" then if clickedElement then if getElementType(clickedElement) == "ped" then local ped = clickedElement if getElementData(ped, "ck.ped") then for i,v in ipairs(getElementsByType("p")) do if getElementData(v, "id") == getElementData(ped, "ck.ped") then ck_window = guiCreateWindow((screenx - 773) / 2, (screeny - 393) / 2, 361, 218, "Body", false) guiWindowSetSizable(ck_window, false) ck_memo = guiCreateMemo(16, 32, 329, 139, "Works.", false, ck_window) guiMemoSetReadOnly(ck_memo, true) ck_close = guiCreateButton(16, 178, 331, 25, "Close Window", false, ck_window) guiSetInputEnabled(true) showCursor(true) addEventHandler("onClientGUIClick", ck_close, ckCloseWindow, false) break end end outputChatBox("Works.") else outputChatBox("Not a CK.") end else outputChatBox("Not a ped.") end else outputChatBox("Not an element.") end end end ) function ckCloseWindow() destroyElement(ck_window) guiSetInputEnabled(false) showCursor(false) end
-
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() local office = engineLoadTXD("cj_office.txd") local house = engineLoadTXD("sfn_office.txd") engineImportTXD(office, 1999) engineImportTXD(house, 9361) end )
-
I get what you mean, I am not so sure why that script didn't work, though you can try this, which is almost the same. addEventHandler("onMarkerHit", root, function(hitElement, matchingDimension) if getElementType(hitElement) == "vehicle" and matchingDimension then return end end )
-
No need. I love MTA, I only said that GUIs are retarded, doesn't mean I don't like MTA. GUI is the least thing, but taking a big piece of everything anyways.
-
GUIs are retarded, too featured way of making things...
-
Basic MTA bug, no fix.
-
EDIT: Hey, you have two setting tags there, try this first. <settings> <!-- MySQL Configuration --> <setting name="@sql.user" value="username"/> <setting name="@sql.password" value="password"/> <setting name="@sql.database" value="database"/> <setting name="@sql.hostname" value="localhost"/> <setting name="@sql.port" value="3306"/> <!-- Only use this on Linux if the normal connection does fail even though using the correct username & password. --> <setting name="@sql.socket" value="/var/run/mysqld/mysqld.sock"/> <!-- Registration --> <setting name="@players.allow_registration" value="1"/><!-- Change to 0 to disable registration and show an error message --> <setting name="@players.registration_error_message" value="Edit this to show the user a message when registration is disabled"/> </settings> OLD: There might be a slight problem with the MySQL, but what I prefer the most if to get the latest copy from the GitHub page. However, here should be the working one. local allowRegistration = tonumber( get( 'allow_registration' ) ) == 1 and true or false local registrationErrorMessage = get( 'registration_error_message' ) if registrationErrorMessage then -- fix for newlines in message registrationErrorMessage = registrationErrorMessage:gsub( "\\n", "\n" ) end addEventHandler( "onResourceStart", resourceRoot, function( ) setElementData( source, "allowRegistration", allowRegistration ) setElementData( source, "registrationErrorMessage", registrationErrorMessage ) end ) local function trim( str ) return str:gsub("^%s*(.-)%s*$", "%1") end addEvent( getResourceName( resource ) .. ":register", true ) addEventHandler( getResourceName( resource ) .. ":register", root, function( username, password ) if source == client then if allowRegistration then if username and password then username = trim( username ) password = trim( password ) -- client length checks are the same if #username >= 3 and #password >= 8 then -- see if that username is free at all local info = exports.sql:query_assoc_single( "SELECT COUNT(userID) AS usercount FROM wcf1_user WHERE username = '%s'", username ) if not info then triggerClientEvent( source, getResourceName( resource ) .. ":registrationResult", source, 1 ) elseif info.usercount == 0 then -- generate a salt (SHA1) local salt = '' local chars = { 'a', 'b', 'c', 'd', 'e', 'f', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } for i = 1, 40 do salt = salt .. chars[ math.random( 1, #chars ) ] end -- create the user if exports.sql:query_free( "INSERT INTO wcf1_user (username,salt,password) VALUES ('%s', '%s', SHA1(CONCAT('%s', SHA1(CONCAT('%s', '" .. sha1( password ) .. "')))))", username, salt, salt, salt ) then triggerClientEvent( source, getResourceName( resource ) .. ":registrationResult", source, 0 ) -- will automatically login when this is sent else triggerClientEvent( source, getResourceName( resource ) .. ":registrationResult", source, 4 ) end else triggerClientEvent( source, getResourceName( resource ) .. ":registrationResult", source, 3 ) end else -- shouldn't happen triggerClientEvent( source, getResourceName( resource ) .. ":registrationResult", source, 1 ) end else -- can't do much without a username and password triggerClientEvent( source, getResourceName( resource ) .. ":registrationResult", source, 1 ) end else triggerClientEvent( source, getResourceName( resource ) .. ":registrationResult", source, 2, registrationErrorMessage ) end end end )
-
Try this. Not sure though, I'd rather want to see the whole script. Client-side local selectedGrid = false local warp = false function vehCreate() if guiGetVisible(grid_cars) == true then selectedGrid = grid_cars elseif guiGetVisible(grid_bikes) == true then selectedGrid = grid_bikes elseif guiGetVisible(grid_air) == true then selectedGrid = grid_air elseif guiGetVisible(grid_misc) == true then selectedGrid = grid_misc end if source == button_vehicle_create_warp then warp = true elseif source == button_vehicle_create then warp = false end selectedVeh1, selectedVeh2 = guiGridListGetSelectedItem(selectedGrid) if selectedVeh1 ~= -1 then textItem = guiGridListGetItemText(selectedGrid, selectedVeh1, selectedVeh2) modelVehID = getVehicleModelFromName(textItem) if not modelVehID then dataItem = guiGridListGetItemData(selectedGrid, selectedVeh1, selectedVeh2) if not dataItem then outputChatBox("Can't retrieve data and name isn't good") else triggerServerEvent("giveVehicle", localPlayer, dataItem, warp) end else triggerServerEvent("giveVehicle", localPlayer, modelVehID, warp) end end Server-side function createVehicle(vehID, warp) local name = getPlayerName(source) outputChatBox("I am " .. name .. ".") local x, y, z = getElementPosition(source) local rx, ry, rz = getElementRotation(source) local veh = createVehicle(vehID, x, y, z + 1, rx, ry, rz) if warp == true then warpPedIntoVehicle(source, veh, 0) else setElementPosition(source, x, y, z + 3) end end addEvent("giveVehicle", true) addEventHandler("giveVehicle", root, createVehicle)
-
To prevent dimension problems and so on, you can try this: local radar = createRadarArea(-466.317, -468.559, -150, -90, 255, 255, 0, 175) local colRectangle = createColRectangle(-466.317, -468.559, -150, -90) function onEnter(hitElement, matchingDimension) if matchingDimension then if (getElementType(player) == "player") then outputChatBox("You entered the zone, welcome.", hitElement, 0, 255, 0) end end end addEventHandler("onColShapeHit", colRectangle, onEnter) function onExit(hitElement, matchingDimension) if matchingDimension then if (getElementType(hitElement) == "player") then outputChatBox("You left the zone, good bye.", hitElement, 0, 255, 0) end end end addEventHandler("onColShapeLeave", colRectangle, onExit)
-
Commands Roll your dice: /roll Server-side triggerClientEvent("new", root, message) local restriction = {} addCommandHandler("roll", function(player, cmd) local playerName = getPlayerName(player) if restriction[playerName] then local sMessage = "You have to wait 30 seconds" outputChatBox(sMessage, player, 255, 0, 0) else restriction[playerName] = true setTimer(restrictionEnd, 100, 1, playerName) local randomroll = math.random(1, 3000) local roller = math.random(1, 4) local weapon = math.random(1, 40) if roller == 1 then givePlayerMoney(player, randomroll) local sMessage = playerName .. '#FFFF00 roll and wins ' .. randomroll .. ' !' outputChatBox(sMessage, root, 255, 255, 0, true) elseif roller == 2 then local sMessage = playerName .. ' roll and is now changed the Weapon ' .. Weapon .. '!' giveWeapon(player, weapon) outputChatBox(sMessage, root, 255, 255, 0, true) end end end ) function restrictionEnd(playerName) restriction[playerName] = nil end Client-side local sMessage = '' function fStart(sText) sMessage = sText end function fDraw() if sMessage ~= '' then dxDrawText("message :", 17.0, 189.0, 61.0, 206.0, tocolor(255, 0, 0, 255), 1.0, "default-bold", "left", "top", false, false, false) dxDrawText(sMessage, 61.0, 189.0, 264.0, 226.0, tocolor(255, 225, 225, 255), 1.0, "default-bold", "left", "top", false, false, false) end end addEvent("new", true) addEventHandler("new", root, fStart) addEventHandler("onClientRender", root, fDraw)
-
He's saying you need to use the lua-tags here. Also known as [ lua ][ /lua ], remember to remove the spaces between the shutters and the names.
-
Need to use the code tags again since lua is bugged somehow. So, you had few errors there: a missing end in the server side code and you had put (player, cmd) in the client side command event, which is not going to work since client-side works with the source without needing to put the source seperately. Commands triggerClientEvent: /wla bindKey: /bindme Server-side addCommandHandler("wla", function(player, cmd, ...) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then triggerClientEvent("yanas", root, yana) end end ) Client-side local button = guiCreateButton(0.7, 0.1, 0.2, 0.1, "Output!", true) local editBox = guiCreateEdit(0.3, 0.1, 0.4, 0.1, "Type your message here!", true) guiEditSetMaxLength(editBox, 128) function outputEditBox () local text = guiGetText(editBox) outputChatBox(text) setTimer(text, 1000, 0) end addEvent("yanas", true) addEventHandler("yanas", root, outputEditBox) addEventHandler("onClientGUIClick", button, outputEditBox) addEventHandler("onClientGUIClick", editBox, outputEditBox) addCommandHandler("bindme", function(cmd) bindKey("F1", "down", outputEditBox) end )