-
Posts
21,935 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Castillo
-
function procesarBuscados(client) local buscados = {} for index, player in ipairs(getElementsByType ( "player" )) do local wlevel = getPlayerWantedLevel (player) if wlevel > 0 then table.insert(buscados, {getPlayerName(player), wlevel}) else table.insert (buscados, {"Nadie es Buscado", "N/a"}) end end setTimer (triggerClientEvent, 1000, 1, client, "listaBuscados", client, buscados) end addEvent("irBuscados", true) addEventHandler( "irBuscados",getRootElement(), procesarBuscados ) Proba con eso.
-
You're messing client and server functions.
-
What server? also, you used onMarkerHit on a client side script, if you use client side markers you must use onClientMarkerHit.
-
local dutyMarker = createMarker ( 1556.33, -1608.37, 13, 'cylinder', 2.0, 0, 0, 225, 132 ) function createCopGui ( hitElement ) PoliceGui = guiCreateWindow(227,106,342,376,"MLAW Police job",false) Have_Job = guiCreateButton(39,313,111,45,"Have job!",false,PoliceGui) Cancel = guiCreateButton(200,312,111,45,"Cancel",false,PoliceGui) Doel = guiCreateMemo(63,44,234,242,"Police Job:\nAs police you will have a hourly payment. Further objectves comming soon!",false,PoliceGui) guiMemoSetReadOnly( Doel,true ) end addEventHandler("onClientMarkerHit", dutyMarker, function (hitElement) if hitElement == localPlayer then createCopGui ( hitElement ) ouputChatBox ("Please choose if you wanna be police.") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox ("The police doesn't want you. Please re-enter the marker.") end showCursor(true) guiSetInputEnabled(true) end end ) function PoliceTeam(button,state) if button == "left" and state == "up" then setPlayerTeam ("Police") triggerServerEvent("PoliceTeam") -- hide the gui, hide the cursor and return control to the player guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end end end
-
Well, then you could have used my code... Deliver = createMarker ( -2211.1455078125, 565.84979248047, 49.442939758301, "checkpoint", 7, 0, 125, 0, getRootElement() ) function Deliver_func ( hitElement, dim ) if getElementType(hitElement) == "player" then veh = getPedOccupiedVehicle ( hitElement ) elseif getElementType(hitElement) == "vehicle" then veh = hitElement end local occupant = getVehicleOccupant(veh) end addEventHandler ( "onMarkerHit", Deliver, Deliver_func ) Should work.
-
My first reply didn't work?
-
Oh, I suposed that was self explained, so yes, separate LUA files.
-
function Deliver_func( hitElementa, dim ) if getElementType(hitElementa) == "vehicle" then local veh = hitElementa local hitElement = getVehicleOccupant(veh) end end
-
Well, a client side and a server side script(s) are different, if you take a look at the MTA wiki, you'll see a list of Server events/functions and Client events/functions, some events/functions are only client side and other's server side only. In the meta.xml the script type must be like type="client" or type="server".
-
That's because you put a string as team, but it requires a team element. function allPlayersPayDay() local allPlayers = getPlayersInTeam( getTeamFromName( "Police" ) ) for index,value in ipairs(allPlayers) do givePlayerMoney ( value, 5000 ) outputChatBox ( "PayTime! You have been given 5K! Enjoy!", value ) end end function onResourceStart(thisResource) setTimer ( allPlayersPayDay, 1000, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart )
-
Deliver = createMarker ( -2211.1455078125, 565.84979248047, 49.442939758301, "checkpoint", 7, 0, 125, 0, getRootElement() ) function Deliver_func ( hitElement, dim ) if getElementType(hitElement) == "player" then veh = getPedOccupiedVehicle ( hitElement ) elseif getElementType(hitElement) == "vehicle" then veh = hitElement end end addEventHandler ( "onMarkerHit", Deliver, Deliver_func )
-
function buttonHandler() if(source == refreshButton)then triggerServerEvent("serverGetAccounts", localPlayer, localPlayer) elseif(source == deleteButton)then local row,col = guiGridListGetSelectedItem(accountGrid) if row and col and row ~= -1 and col ~= -1 then local targetAccount = guiGridListGetItemText(accountGrid, row, 1) triggerServerEvent("requestAccountDelete", localPlayer, targetAccount) end end end addEventHandler("onClientGUIClick", getResourceRootElement(getThisResource()), buttonHandler) function deleteAccount(targetAccount) if getAccount(targetAccount) then removeAccount(getAccount(targetAccount)) end end addEvent("requestAccountDelete", true) addEventHandler("requestAccountDelete", getRootElement(), deleteAccount)
-
Well, I can see that this is a total mess, first, getAccounts() doesn't return the account name, but the account himself, so you need to make a temp table and store the account name (I guess you want the account name), second, you trigger the event in the refresh? that's HIGHLY wrong as it will never trigger for the first time, and that would be useless, also, you send the accounts table but then you never use it? "getElementsByType("account")"? what is that? -- client side: function createAccountWindow() mainWnd = guiCreateWindow(307, 256, 268, 361, "Account Manager", false) accountGrid = guiCreateGridList(9, 23, 249, 228, false, mainWnd) guiGridListSetSelectionMode(accountGrid, 2) refreshButton = guiCreateButton(12, 258, 91, 26, "Refresh", false, mainWnd) guiGridListAddColumn(accountGrid, "Account Name", 0.3) guiSetVisible(mainWnd, true) showCursor(true) triggerServerEvent("serverGetAccounts", localPlayer, localPlayer) end addCommandHandler("accountmanager", createAccountWindow) function refreshGridlist(accountTable) guiGridListClear(accountGrid) for index, account in ipairs(accountTable) do local row = guiGridListAddRow(accountGrid) guiGridListSetItemText(accountGrid, row, 1, tostring(account), false, false) end end addEvent("serverGivesAccounts", true) addEventHandler("serverGivesAccounts", getRootElement(), refreshGridlist) addCommandHandler("refac", function () triggerServerEvent("serverGetAccounts", localPlayer, localPlayer) end) -- server side: function getTheAccounts(client) accountTable = getAccounts() local tempTable = {} if(#accountTable == 0)then outputDebugString("No accounts in database!") else for index, account in pairs(accountTable) do table.insert(tempTable, getAccountName(account)) end triggerClientEvent(client, "serverGivesAccounts", client, tempTable) end end addEvent("serverGetAccounts", true) addEventHandler("serverGetAccounts", getRootElement(), getTheAccounts)
-
I told you to check if the vehicle and sound exists, not the PATH.
-
Try debugging the script, check if the vehicle exists, the sound, and so on.
-
AguuS, please don't bump 4 months old topics, the question was already answered.
-
MTA no es compatible con MTA?
-
-- server side --i know from radio3d script function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(angle+90) local plusX = math.cos(a) * dist local plusY = math.sin(a) * dist return x+plusX, y+plusY end xmlFile = xmlLoadFile ("radios.xml") radios = {} stations = {} stationsNames = {} function loadStations () if xmlFile then local children = xmlNodeGetChildren (xmlFile) for k,v in ipairs(children) do local radioTable = xmlNodeGetAttributes (v) for name,value in pairs(radioTable) do --outputChatBox (tostring(value)) if name == "name" then stationName = value elseif name == "path" then stationPath = value end end --outputChatBox ("name = " .. tostring(stationName) .. ", path = " .. tostring(stationPath)) stations[stationName] = stationPath table.insert (stationsNames, 1, stationName) end table.sort (stationsNames) end end loadStations () function createRadio (player, station) if station then local stationPath = stations[station] if stationPath then local commandantje = getPedOccupiedVehicle(player) if ( commandantje ) then local x,y,z = getElementPosition( player ) local rx,ry,rz = getElementRotation ( player ) local newX, newY = getPointFromDistanceRotation (x,y, 1.5, rz) local newZ = z - 1 triggerClientEvent ( "onNewRadioCreate", getRootElement(), commandantje, path ) outputChatBox ("New station: " .. station .. " created, path: " .. tostring(stationPath), player, 0,220,0) table.insert (radios, 1, {newX, newY, newZ, path}) -- zapisuje informacje o radiu dla nowych graczy else outputChatBox ("error", player, 220, 0, 0) --outputChatBox ("You choose wrong station, avaible stations:", player, 220, 0, 0) --for k,v in ipairs(stationsNames) do --outputChatBox ("-" .. v, player) end end else outputChatBox ("error", player, 220, 0, 0) --outputChatBox ("Choose radio to create, avaible stations:", player,220,0,0) --for k,v in ipairs(stationsNames) do -- outputChatBox ("-" .. v, player) --end end end addEvent ("onClientRadioCreate", true) addEventHandler ("onClientRadioCreate", getRootElement(), createRadio) --addCommandHandler ("radio", createRadio) function onJoin (player) if radios then triggerClientEvent (player, "sendAllRadios", getRootElement(), radios, stationsNames, stations) end end addEvent ("requestForRadios", true) addEventHandler ("requestForRadios", getRootElement(), onJoin) Try it.
-
--Client Side GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Grid = {} GUIEditor_Window[1] = guiCreateWindow(436,285,486,412,"Boxen In Auto -- BIA",false) GUIEditor_Button[7] = guiCreateButton(21,40,175,49,"Box Links",false,GUIEditor_Window[1]) GUIEditor_Button[8] = guiCreateButton(251,40,175,49,"Box Rechts",false,GUIEditor_Window[1]) GUIEditor_Button[10] = guiCreateButton(251,274,175,49,"Close",false,GUIEditor_Window[1]) GUIEditor_Grid[1] = guiCreateGridList(21,144,183,259,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) guiSetVisible(GUIEditor_Window[1],false) guiGridListAddColumn(GUIEditor_Grid[1],"Muziek",0.2) for i = 1, 1 do guiGridListAddRow(GUIEditor_Grid[1]) end guiGridListSetItemColor(GUIEditor_Grid[1],0,1,255,0,0,255) GUIEditor_Button[9] = guiCreateButton(251,154,175,49,"Play",false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(258,231,182,80,"Dit is nog de Beta Versie",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255, 0 ,0) guiSetFont(GUIEditor_Label[1],"default-bold-small") function bia() guiSetVisible (GUIEditor_Window[1],true) showCursor(true) end addCommandHandler ( "bia", bia ) addEventHandler("onClientGUIClick",getRootElement(), function (player) if (source == GUIEditor_Button[7]) then money = getPlayerMoney (source) if (money < 0) then outputChatBox ("U heeft niet genoeg geld!",225,0,0) else player = getLocalPlayer() outputChatBox ("Box Gemaakt!",225,0,255) triggerServerEvent ( "boksL", getLocalPlayer(), getLocalPlayer()) -- You need to trigger getLocalPlayer() twice to be able to use the argument in server side. end elseif (source == GUIEditor_Button[10]) then money = getPlayerMoney (source) if (money < 0) then outputChatBox ("U heeft niet genoeg geld!",225,0,0) else guiSetVisible (GUIEditor_Window[1],false) showCursor (false) end end end) --Server Side function boxl ( player ) local bestuurderr = getPedOccupiedVehicle(player) local box = createObject ( 2232, 0, 0, 0 ) attachElements ( box, bestuurderr, 0.49, -1.8, 0.2, 0, 0, -20 ) setObjectScale ( box, 0.4 ) setElementCollisionsEnabled(box, false) end addEvent( "boksL", true ) addEventHandler( "boksL", getRootElement(), boxl )
-
XML can be edited with a text editor.
-
Do you mean storing the text's in a XML file? if so, then check the XML functions: https://wiki.multitheftauto.com/wiki/Ser ... _functions
-
function vehicleDamage(loss) local vehHealth = getElementHealth(source) if (vehHealth < 300) then setElementHealth(source, 300) setVehicleEngineState(source, false) end end addEventHandler("onVehicleDamage", root, vehicleDamage) Should work.
