-
Posts
1,491 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Walid
-
Restarting a MTA Server without disconnect the players
Walid replied to joaosilva099's topic in Scripting
funny question -
use removeEventHandler()
-
didn't work because listveh it's a table so ou can't use (if source == listveh then). Try this it should work local listveh = { {602, 1681.0999755859, 999.59997558594, 10.7}, {602, 1676.0999755859, 999.59997558594, 10.7}, {602, 1671.0999755859, 999.59997558594, 10.7}, } function createVehicles() for i , v in pairs (listveh) do vehicle = createVehicle (v[1],v[2],v[3],v[4]) addEventHandler ( "onVehicleStartEnter",vehicle, lockteamAcars ) end end addEventHandler("onResourceStart", resourceRoot, createVehicles) function lockteamAcars( player, seat, jacked ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local teamName = getTeamName(playerTeam) if ( teamName ~= "Team A" ) then -- Your code end end end -- also you can add team names inside the table.
-
Try this it should work local listveh = { {602, 1681.0999755859, 999.59997558594, 10.7}, {602, 1676.0999755859, 999.59997558594, 10.7}, {602, 1671.0999755859, 999.59997558594, 10.7}, } function createVehicles() for i , v in pairs (listveh) do vehicle = createVehicle (v[1],v[2],v[3],v[4]) addEventHandler ( "onVehicleStartEnter",vehicle, lockteamAcars ) end end addEventHandler("onResourceStart", resourceRoot, createVehicles) function lockteamAcars( player, seat, jacked ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local teamName = getTeamName(playerTeam) if ( teamName ~= "Team A" ) then -- Your code end end end -- also you can add team names inside the table.
-
Try this -- Client side local ped = createPed(0, 1616.44, -1506.98, 14.21,90) function onPedClick(button, state, absX, absY, wx, wy, wz, element) if (element and getElementType(element) == "ped" and state=="down") then local x, y, z = getElementPosition(localPlayer) if (element == ped) then if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then guiSetVisible(Window, true) showCursor (true) end end end end addEventHandler("onClientClick", root, onPedClick) function Location1() markerlocation1 = createMarker (1602.38, -1448.85, 12.55, "cylinder", 2, 255, 0, 0, 255) blipLS = createBlipAttachedTo (markerlocation1, 51) addEventHandler( "onClientMarkerHit", markerlocation1, function ( hitPlayer, d ) if isElement(markerlocation1) then destroyElement(markerlocation1) destroyElement(blipLS) end triggerServerEvent("doPayClient", hitPlayer) end ) end function onButtonClick() if (source == reject) then setCameraTarget(localPlayer) guiSetVisible(Window, false) showCursor(false) elseif (source == accept) then if (guiRadioButtonGetSelected(location1)) then triggerServerEvent ("givePVehicle",getLocalPlayer()) Location1() guiSetVisible (Window,false) showCursor (false) end end end addEventHandler("onClientGUIClick", guiRoot, onButtonClick) -- server side local vehicles = {} addEvent("doPayClient", true) addEventHandler( "doPayClient", root, function() givePlayerMoney(source, 2000) setPlayerWantedLevel(source, getPlayerWantedLevel(source)+1) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end end ) addEvent("givePVehicle", true) addEventHandler( "givePVehicle", root, function() local vehicle = createVehicle (482,1605.42, -1472.97, 13.58,0,0,0) vehicles[source] = vehicle warpPedIntoVehicle(source,vehicles[source]) end )
-
Dosen't wroks because there is no event attached to Location1() function.
-
-- Client side local ped = createPed(0, 1616.44, -1506.98, 14.21,90) function onPedClick(button, state, absX, absY, wx, wy, wz, element) if (element and getElementType(element) == "ped" and state=="down") then local x, y, z = getElementPosition(localPlayer) if (element == ped) then if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then guiSetVisible(Window, true) showCursor (true) end end end end addEventHandler("onClientClick", root, onPedClick) function Location1() markerlocation1 = createMarker (1602.38, -1448.85, 12.55, "cylinder", 2, 255, 0, 0, 255) blipLS = createBlipAttachedTo (markerlocation1, 51) triggerServerEvent("givePVehicle", localPlayer) addEventHandler( "onClientMarkerHit", markerlocation1, function ( hitPlayer, d ) if isElement(markerlocation1) then destroyElement(markerlocation1) destroyElement(blipLS) end triggerServerEvent("doPayClient", hitPlayer) end ) end function onButtonClick() if (source == reject) then setCameraTarget(localPlayer) guiSetVisible(Window, false) showCursor(false) elseif (source == accept) then if (guiRadioButtonGetSelected(location1)) then triggerServerEvent ("givePVehicle",getLocalPlayer()) guiSetVisible (Window,false) showCursor (false) end end end addEventHandler("onClientGUIClick", guiRoot, onButtonClick) -- Server side local vehicles = {} addEvent("doPayClient", true) addEventHandler( "doPayClient", root, function() givePlayerMoney(source, 2000) setPlayerWantedLevel(source, getPlayerWantedLevel(source)+1) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end end ) addEvent("givePVehicle", true) addEventHandler( "givePVehicle", root, function() local vehicle = createVehicle (482,1605.42, -1472.97, 13.58,0,0,0) vehicles[source] = vehicle warpPedIntoVehicle(source,vehicles[source]) end )
-
[quote name=..&G:..]Doesn't work... and there are also no errors.. lol :3 working fine for me , post full code here.
-
function selectedImage() local row = guiGridListGetSelectedItem(donItemsList) local currentImage = tostring(guiGridListGetItemText(donItemsList,row,1)) if(currentImage == "") or (currentImage == " ") then guiStaticImageLoadImage(donItemsPic,"images/default.png") else if(fileExists("images/"..string.lower(currentImage)..".png")) then guiStaticImageLoadImage(donItemsPic,"images/"..string.lower(currentImage)..".png") else guiStaticImageLoadImage(donItemsPic,"images/default.png") end end end -- Event handler put it inside the GUI part addEventHandler ( "onClientGUIClick", donItemsList, selectedImage,false )
-
lol what's your gridList name i think it's donItemsList right.
-
function selectedImage() local row = guiGridListGetSelectedItem(donBunuriList) local currentImage = tostring(guiGridListGetItemText(donBunuriList,row,1)) if(currentImage == "") or (currentImage == " ") then guiStaticImageLoadImage(donItemsPic,"images/default.png") else if(fileExists("images/"..string.lower(currentImage)..".png")) then guiStaticImageLoadImage(donItemsPic,"images/"..string.lower(currentImage)..".png") else guiStaticImageLoadImage(donItemsPic,"images/default.png") end end end -- add your event handler onClientGUIClick
-
i'm pretty sure that it's not your code.
-
You write all of this and you don't know how to fix it ???
-
Try this it should work. addEventHandler("onClientResourceStart",resourceRoot, function() Wind = guiCreateWindow(399, 210, 243, 248, "Create Marker", false) guiWindowSetSizable(Wind, false) guiSetVisible(Wind, false) Types = guiCreateComboBox(78, 32, 155, 98, "Corona", false, Wind) guiComboBoxAddItem(Types, "Arrow") guiComboBoxAddItem(Types, "Cylinder") guiComboBoxAddItem(Types, "Check Point") guiComboBoxAddItem(Types, "Corona") guiComboBoxAddItem(Types, "Ring") lab = guiCreateLabel(9, 36, 69, 18, "Marker Type", false, Wind) lab2 = guiCreateLabel(9, 84, 69, 18, "Marker Size", false, Wind) Size = guiCreateMemo(78, 74, 155, 31, "From 1 to 10", false, Wind) lab3 = guiCreateLabel(10, 130, 69, 18, "Marker Color", false, Wind) ColorR = guiCreateMemo(79, 120, 35, 31, "R", false, Wind) ColorG = guiCreateMemo(118, 120, 39, 31, "G", false, Wind) ColorB = guiCreateMemo(160, 120, 39, 31, "B", false, Wind) lab4 = guiCreateLabel(9, 173, 69, 18, "Marker Alpha", false, Wind) Alpha = guiCreateMemo(79, 170, 154, 31, "From 0 to 250", false, Wind) Create = guiCreateButton(10, 209, 94, 29, "Create", false, Wind) Close = guiCreateButton(129, 209, 94, 29, "Close", false, Wind) addEventHandler ( "onClientGUIClick", Create, creat, false ) addEventHandler ( "onClientGUIClick", Close, clos, false ) end ) function OpenGui() guiSetVisible(Wind, not guiGetVisible(Wind)) showCursor(guiGetVisible(Wind)) end addCommandHandler ( "cm",OpenGui) function clos ( ) guiSetVisible (Wind, false) showCursor (false) end function creat ( ) local x, y, z = getElementPosition ( localPlayer ) local types = guiComboBoxGetSelected ( Types ) local size = guiGetText ( Size ) local r, g, b, a = guiGetText ( ColorR ), guiGetText ( ColorG ), guiGetText ( ColorB ), guiGetText ( Alpha ) local mc = createMarker ( x, y, z, types, size, r, g, b, a ) if ( mc ) then outputChatBox ( "Marker created successfully" ) else outputChatBox ( "Error" ) end end
-
You need to use getElementData Example function onVehicleEnter ( thePlayer ) if ( not Barcos [ getElementModel ( source ) ] ) then return end local occupation = -- use getElemenData here to check the player job if occupation and occupation ~= "" then if (occupation == "Pesquero" ) then getNewBarcoLocation ( thePlayer ) end end end addEventHandler ( "onVehicleEnter", root, onVehicleEnter )
-
be patient bro , anyways try this local vehicleType = {["BMX"] = true, ["Bike"] = true} local controls = {"vehicle_secondary_fire","vehicle_secondary_fire","aim_weapon","vehicle_fire", "fire"} function disableFire ( theVehicle, seat ) if theVehicle then local Type = getVehicleType(theVehicle) if vehicleType[Type] then for i, v in pairs(controls) do toggleControl(tostring(v), false) end else for i, v in pairs(controls) do toggleControl(tostring(v), true) end end end end addEventHandler ( "onClientPlayerVehicleEnter", getRootElement(), disableFire )
-
Try to create an export function then use it everytime the player buy something. Example function to take the player money. function takeMoney(player, amount) if (not isElement(player)) then return end if not tonumber(amount) then return end local account = getPlayerAccount(player) if account and not isGuestAccount(account) then local mo = getElementData(player,"Money") or 0 if mo then local moneyToTake = math.floor(tonumber(mo) - tonumber(amount)) takePlayerMoney(player, tonumber(amount)) setElementData(player,"Money",moneyToTake) setAccountData(account,"Money",moneyToTake) end end end About the HUD you need to use getElementData(localPlayer,"Money") .
-
you can't do it with "onPlayerLogin" event. try to use sth like this -- Example function yourFunctionName() local players = getElementsByType ( "player" ) for i , v in ipairs(players) do -- Your code here end end -- setTimer here
-
As i told you there is many things wrong . timesToExecute must be 1 not 0.