-
Posts
1,105 -
Joined
-
Last visited
Everything posted by Aibo
-
well i dont know how your editBox called where client puts line number to go to. replace someLineNumberEditBox with that variable function explode(div,str) if (div=='') then return false end local pos,arr = 0,{} for st,sp in function() return string.find(str,div,pos,true) end do table.insert(arr,string.sub(str,pos,st-1)) pos = sp + 1 end table.insert(arr,string.sub(str,pos)) return arr end --[[-- you don't need this part: local mystring = guiGetText(script_memo) local exp = explode("\n", mystring) local targetLine = tonumber ( guiGetText ( script_memo ) ) local index=0 for i=1, targetLine-1 do index = index + exp[i]:len() end --]]-- since its in a function now function getLineIndex(mystring, targetLine) local exp = explode("\n", mystring) local index=0 for i=1, targetLine-1 do index = index + exp[i]:len() end return index end
-
all scoreboard exported functions are server-side (except "setScoreboardForced"), and in that script it is called from client, hence the error. PS: klesh. you've got the ready script for car health to scoreboard (which is ALL server-side), its a matter of few lines editing to add deaths, and you again trying to do something in some strange way through the client. its like you dont even understand what you're doing. i mean at all.
-
add it as a function and call it to get index for guiMemoSetCaretIndex when "goto" button clicked: function getLineIndex(mystring, targetLine) local exp = explode("\n", mystring) local index=0 for i=1, targetLine-1 do index = index + exp[i]:len() end return index end -- onClientGUIClick your "goto line" button: guiMemoSetCaretIndex(script_memo, getLineIndex(guiGetText(script_memo), guiGetText(someLineNumberEditBox)))
-
he wants to add player's vehicle health to scoreboard. server-side: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn("Car Health") end) function scoreboardCarHealthUpdate(a,b,c) if getElementType(source) == "player" then player = source car = getPedOccupiedVehicle(player) elseif getElementType(source) == "vehicle" then player = getVehicleController(source) car = source end if player and car then local damage = 0 if not b and not c then damage = a end local health = math.floor((getElementHealth(car)-250-damage)/750*100) setElementData(player, "Car Health", health.."%") elseif player then setElementData(player, "Car Health", "---") end end addEventHandler("onVehicleDamage", getRootElement(), scoreboardCarHealthUpdate) addEventHandler("onVehicleEnter", getRootElement(), scoreboardCarHealthUpdate) addEventHandler("onPlayerPickUpRacePickup", getRootElement(), scoreboardCarHealthUpdate) addEventHandler("onPlayerWasted", getRootElement(), scoreboardCarHealthUpdate)
-
you could at least mention that you used my CGUI.png (ok, with color overlay) and/or link the original like this, but he colored it
-
-- server: function sendMaps(player) local mapTable = {} for i, map in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName("race"))) do table.insert(mapTable, getResourceInfo(map, "name")) -- this will add map to list by MAP NAME --table.insert(mapTable, getResourceName(map)) -- this will add map by its RESOURCE NAME end triggerClientEvent(player, "mapListUpdate", getRootElement(), mapTable) end -- client: addEvent("mapListUpdate", true) addEventHandler("mapListUpdate", getRootElement(), function(maps) guiGridListClear(list) for i, map in ipairs(maps) do local row = guiGridListAddRow(list) guiGridListSetItemText(list, row, names, map, false, false) end end)
-
see post above yours by Antibird, those functions will be of more use to you i bet.
-
https://wiki.multitheftauto.com/wiki/Split
-
you should read about/look into map editor/map files, how objects are saved there.
-
with some combination ot string functions i suppose, need to think about best way
-
people somehow like to flood the chat with old !commands, i dont know why. you better something like this to be able to use /command via !command: addEventHandler("onPlayerChat", getRootElement(), function(text) if text:sub(1, 1) == "!" then local command = gettok(text, 1, 32) if #command > 1 then cancelEvent() -- if event is not cancelled, command will be executed BEFORE chat output that trigered it outputChatBox(getPlayerName(source)..": "..text, getRootElement(), 255, 255, 255, true) -- comment/delete ^previous^ line to hide command input executeCommandHandler(command:gsub("!", ""), source, text:gsub(command, "")) end end end) basically when player type !something in chat, /something command will be executed, including all arguments. that is, of course, if you already created it with addCommandHandler(). and your resource must have access to executeCommandHandler() function.
-
by using XML fuctions: https://wiki.multitheftauto.com/wiki/XmlCreateFile
-
index is not line index, its character index. you can calcutate positions of line breaks (\n) and move to the next symbol by guiMemoSetCaretIndex
-
1. GUIEditor_Button is not a table, so GUIEditor_Button[1] will cause error 2. guiSetText(e_u, getPlayerName(player)) -- player is not defined 3. if ( source == Btn_log ) then -- Btn_log not defined 4. elseif ( source == Btn_reg ) then -- Btn_reg not defined 5. guiSetVisible ( loginwindow, false ) -- loginwindow not defined 6. addEventHandler ( "onClientResourceStart", getResourceRoot,start) -- getResourceRoot not defined this is some kind of a frankenstein script
-
no idea, 'cause i dont really get what you want. labels in code? dont think thats needed.
-
you cant add 1 line to it to switch to white when off? blueTimers = {} -- vehicle table for your blue timers redTimers = {} -- for your red timers function EmergencyLights(source) local theVehicle = getPedOccupiedVehicle(source) -- getPlayerOccupiedVehicle() is deprecated -- thevehicle must be local, since we can have more than 1 player with vehicles if theVehicle then if getVehicleOverrideLights(theVehicle) ~= 2 then setVehicleOverrideLights(theVehicle, 2) blueTimers[theVehicle] = setTimer(setLight, 400, 1, theVehicle) -- vehicle element must be passed to the timer/function, since theVehicle is now local else setVehicleOverrideLights(theVehicle, 0) setVehicleHeadLightColor(theVehicle, 255, 255, 255) -- this if isTimer(blueTimers[theVehicle]) then killTimer(blueTimers[theVehicle]) end if isTimer(redTimers[theVehicle]) then killTimer(redTimers[theVehicle]) end end end end function setLight(car) setVehicleHeadLightColor(car, 0, 0, 255) redTimers[car] = setTimer(setLight2, 400, 1, car) end function setLight2(car) setVehicleHeadLightColor(car, 255, 0, 0) blueTimers[car] = setTimer(setLight, 400, 1, car) end addCommandHandler("elights", EmergencyLights)
-
in the script i posted above it is turned on/off by the same command.
-
help yourself: test if event triggered, and that doesnt mean putting chat output near setElementPosition. if you have problems with such simple script (because others have even tested it and it works) — something is wrong on your side, and noone here can say with 100% certainty what exactly.
-
man, you cant even write straight, let alone script. and what is this topic about then: viewtopic.php?f=91&t=30325
-
it ends on line 36, am i wrong? anyway, is you script even runs? do you see your markers? place some output to debug/chat/console in various parts to check is event even triggered or where it stalls. do something.
-
and why is that?
-
cancelling the project on the second day — that's bold.
-
as i recall, race resource doesn't have event for destruction derby winner (though it should have, imo) you can add it yourself though: open race/modes/destructionderby.lua, around line 67: if #activePlayers == 1 then self.rankingBoard:add(activePlayers[1], timePassed) showMessage(getPlayerName(activePlayers[1]) .. ' is the final survivor!', 0, 255, 0) triggerEvent("onPlayerDestructionDerbyWin", getRootElement(), activePlayers[1]) -- add this line to trigger event end
-
try guiSetInputEnabled(true) i mean guiSetInputEnabled(false) looks like it has nothing to do with it, sorry actually it should work fine right after showCursor(true), it's just open chatbox/console prevent onClientClick event somehow.
