-
Posts
656 -
Joined
-
Last visited
-
Days Won
2
Everything posted by John Smith
-
createEffect is client sided function
-
Perhaps he wants people with Console ACL not to be banned/kicked?
-
The fact that he is suggesting something doesn't mean that he has to create it. https://bugs.multitheftauto.com/view.php?id=4571
-
try replacing some of fonts like pricedown with your custom font by renaming your custom font to e.g pricedown.ttf and replace it at mta directory (but i've never done this so idk if it will work)
-
Also when you open server browser you can open tab called 'Recent' and there you will see every server that you've played so far, and that server should be there
-
Seems like i was right
-
/refresh and /refreshall
-
To accomplish that you need shaders if you need help with shaders, ask Ren712
-
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
how did i read the scripts then? -
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
to manipulate or retrieve data from another resource you just add ':' before resourceName and it's supposed to work fine i have tried everything, and i don't get it how this script loader works on 2 maps perfectly fine(unless map creator has bugs in his map scripts) and all other maps, nothing works here's a preview of the warning that i'm getting: I don't know why this is happening, usually it would happen(i think) if resource which im trying to access is not loaded but i really doubt that as my race gamemode starts map resource before it triggers custom script loading edit: i have tried manually opening the path with server side and client side, appears that on client side it's impossible to load resource files (how didn't i realise this before?) so i'm gonna test it out now, and thanks fellas for help edit2: that was the issue! Thanks guys, it works now and if i need help again i will write in here ^^ -
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
ok thanks, but do you know what could be the issue of my overrider now not loading scripts? i mean it can load scripts from 2 maps but when i add new maps, it doesn't load scripts because fileOpen says unable to load file 'path' and the path is correct e.g 'fileOpen' could not open ':resourcename/client.lua' -
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
Okay thanks, but what would exactly be the security issues when not using an environment? edit: hi, im running into problems again it fails to open files (loadScript function) even though the filepath is correct... it just says that fileOpen is unable to load file :resourcename/client.lua for example am i doing something wrong? -
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
Oh wow haha thanks man i didn't even see that mistake by the way, i'm guessing that in certain environment all functions have to be defined by the coder so, you're recommending this so that scripts can execute only the functions that i've coded into the enviorment or? btw it would be something like this? local environment = { -- example of environment print = print; outputChatBox = outputChatBox; }; -
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
_playSound = playSound; _engineLoadTXD = engineLoadTXD; _engineReplaceModel = engineReplaceModel; _engineReplaceCOL = engineReplaceCOL; _createMarker = createMarker; _createObject = createObject; _createVehicle = createVehicle; _createPed = createPed; _addEventHandler = addEventHandler; _outputChatBox = outputChatBox; _getThisResource = getThisResource; _bindKey = bindKey; _addCommandHandler = addCommandHandler; --todo engineLoadDFF --todo dxCreateShader local environment = {}; local currentResource; local arena = { sounds = {}; -- done dffs = {}; -- done txds = {}; -- done cols = {}; -- done objects = {}; -- done markers = {}; -- done vehicles = {}; -- done peds = {}; -- done handlers = {}; -- done binds = {}; -- done commands = {}; -- done }; local dimension = 0; --outputChatBox = function() end; function playSound(path,looped) _outputChatBox("custom playSound path "..path,255,0,0) sound = _playSound(":"..getResourceName(currentResource).."/"..path,looped); if sound then table.insert(arena.sounds,sound); end; return sound end; function engineLoadTXD(path) local txd = _engineLoadTXD(":"..getResourceName(currentResource).."/"..path); table.insert(arena.txds,txd) return txd; end; function engineReplaceModel(dff,model) table.insert(arena.dffs,model); return _engineReplaceModel(dff,model); end; function engineReplaceCOL(col,model) table.insert(arena.cols,model); return _engineReplaceCOL(col,model); end; function createMarker(...) local marker = _createMarker(...); setElementDimension(marker,dimension) table.insert(arena.markers,marker); return marker; end; function createObject(...) local object = _createObject(...); setElementDimension(object,dimension) table.insert(arena.objects,object); return object; end; function createVehicle(...) local veh = _createVehicle(...); setElementDimension(veh,dimension) table.insert(arena.vehicles,veh); return veh; end; function createPed(...) local ped = _createPed(...); setElementDimension(ped,dimension); table.insert(arena.peds,ped); return ped; end; function addEventHandler(eventName,attachedTo,handlerFunction,getPropagated,priority) if eventName == "onClientResourceStart" then setTimer(handlerFunction,1000,1) end; table.insert(arena.handlers,{eventName,attachedTo,handlerFunction}); return _addEventHandler(eventName,attachedTo,handlerFunction,getPropagated,priority); end; function getThisResource() return currentResource; end; function bindKey(key,keystate,...) table.insert(arena.binds,{key,keystate,...}); return _bindKey(key,keystate,...); end; function addCommandHandler(name,func,caseSensitive) table.insert(arena.commands,{name,func,caseSensitive}); return _addCommandHandler(name,func,caseSensitive); end; function loadScript(res,script) dimension = getElementDimension(source); currentResource = getResourceFromName(res); local path = ":"..getResourceName(currentResource).."/"..script; local file = fileOpen(path); local content = fileRead(file,fileGetSize(file)); local f = loadstring(content) --setfenv(f,environment) pcall(f); fileClose(file); end; addEvent("onScriptLoadRequest",true); addEventHandler("onScriptLoadRequest",root,loadScript); function unloadScripts() environment = nil; currentResource = nil; dimension = nil; for _,v in pairs(arena.sounds) do stopSound(v); destroyElement(v); end; for _,v in pairs(arena.txds) do destroyElement(v); end; for _,v in pairs(arena.dffs) do engineRestoreModel(v); end; for _,v in pairs(arena.cols) do engineRestoreCOL(v); end; for _,v in pairs(arena.markers) do destroyElement(v) end; for _,v in pairs(arena.objects) do destroyElement(v); end; for _,v in pairs(arena.vehicles) do destroyElement(v); end; for _,v in pairs(arena.peds) do destroyElement(v); end; for _,v in pairs(arena.handlers) do removeEventHandler(v[1],v[2],v[3]); end; for _,v in pairs(arena.binds) do unbindKey(v[1],v[2],v[3]); end; for _,v in pairs(arena.commands) do removeCommandHandler(v[1],v[2]); end; setWaterLevel(0) resetSkyGradient() resetWaterColor() resetWaterLevel() setWaveHeight(0) resetHeatHaze() resetWindVelocity() resetAmbientSounds() resetWorldSounds() resetRainLevel() resetSunSize() resetSunColor() resetFogDistance() resetFarClipDistance() setGravity(0.008) setGameSpeed(1) setCloudsEnabled(false) arena = { sounds = {}; -- done dffs = {}; -- done txds = {}; -- done cols = {}; -- done objects = {}; -- done markers = {}; -- done vehicles = {}; -- done peds = {}; -- done handlers = {}; -- done binds = {}; commands = {}; }; _outputChatBox("onScriptUnloadRequest") end; addEvent("onScriptUnloadRequest",true); addEventHandler("onScriptUnloadRequest",root,unloadScripts); addEventHandler("onClientResourceStop",resourceRoot,unloadScripts); -
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
thanks, i've already overriden addEventHandler but didn't add that onClientResourceStart part.. about function enviorment: i've never rly worked with it, i tried it in my code but it messed everything up so for now i'd just like to stick to not secure way until this starts working however i am having issues with this overrider here are some parts of code that could be causing unwanted things: function unloadScripts() environment = nil; -- currently not being even used currentResource = nil; dimension = nil; for _,v in pairs(arena.sounds) do stopSound(v); destroyElement(v); --returns warning, probably impossible thing to do anyway? end; for _,v in pairs(arena.txds) do destroyElement(v); end; for _,v in pairs(arena.dffs) do engineRestoreModel(v); end; for _,v in pairs(arena.cols) do engineRestoreCOL(v); end; for _,v in pairs(arena.markers) do destroyElement(v) end; for _,v in pairs(arena.objects) do destroyElement(v); end; for _,v in pairs(arena.vehicles) do destroyElement(v); end; for _,v in pairs(arena.peds) do destroyElement(v); end; for _,v in pairs(arena.handlers) do removeEventHandler(v[1],v[2],v[3]); end; for _,v in pairs(arena.binds) do unbindKey(v[1],v[2],v[3]); end; for _,v in pairs(arena.commands) do removeCommandHandler(v[1],v[2]); end; setWaterLevel(0) resetSkyGradient() resetWaterColor() resetWaterLevel() setWaveHeight(0) resetHeatHaze() resetWindVelocity() resetAmbientSounds() resetWorldSounds() resetRainLevel() resetSunSize() resetSunColor() resetFogDistance() resetFarClipDistance() setGravity(0.008) setGameSpeed(1) setCloudsEnabled(false) arena = { sounds = {}; -- done dffs = {}; -- done txds = {}; -- done cols = {}; -- done objects = {}; -- done markers = {}; -- done vehicles = {}; -- done peds = {}; -- done handlers = {}; -- done binds = {}; -- done commands = {}; -- done }; _outputChatBox("onScriptUnloadRequest") end; addEvent("onScriptUnloadRequest",true); addEventHandler("onScriptUnloadRequest",root,unloadScripts); addEventHandler("onClientResourceStop",resourceRoot,unloadScripts); thing seem to work fine when map first time initializes, but after unloadScripts() it doesn't work anymore. simply the scripts dont get loaded should i give more info or something? i dont have any specific errors considering this -
Is that sarcasm? Hi Sheldon
-
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
hello, i have tried making wrapper(i prefer calling it overrider) but it doesnt work properly for some reason this is example of one function which doesnt work properly in overrider _playSound = playSound; function playSound(path,looped) _outputChatBox("custom playSound path "..path,255,0,0) -- this playSound function doesn't even get executed sound = _playSound(path,looped); if sound then table.insert(arena.sounds,sound); end; end; function loadScript(res,script) currentResource = getResourceFromName(res); local path = ":"..getResourceName(currentResource).."/"..script; local file = fileOpen(path); local content = fileRead(file,fileGetSize(file)); local f = loadstring(content) pcall(f); fileClose(file); end; addEvent("onScriptLoadRequest",true); addEventHandler("onScriptLoadRequest",root,loadScript); this script above for example loads this map script: function startMusic() setRadioChannel(0) song = playSound("music2.mp3",true) outputChatBox("#ffffff* #C0FF3ETurn on/off Music Using #FFFFFF\"M\"",255,255,255,true) end function makeRadioStayOff() setRadioChannel(0) cancelEvent() end function toggleSong() if not songOff then setSoundVolume(song,0) songOff = true removeEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) else setSoundVolume(song,1) songOff = false setRadioChannel(0) addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) end end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startMusic) addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) addEventHandler("onClientPlayerVehicleEnter",getRootElement(),makeRadioStayOff) addCommandHandler("musicmusic",toggleSong) bindKey("m","down","musicmusic") addEventHandler("onClientResourceStop",getResourceRootElement(getThisResource()),startMusic) and it loads the code provided but for example it doesn't play music and when i press key M it says WARNING: Bad 'sound/player' pointer @ 'setSoundVolume'(1) [string "function startMusic()..."] i would appreciate if you could help me solve this issue -
i believe that sniper zoom effect is made by changing FOV value, but currently you can't get FOV value in mta because its disabled
-
You've said in first post that you're unable to get event when player gets on top of car and starts hitting it and for other melee weapons you could store their ids and then in client script check if table[weapon] and then triggerServerEvent but for the first case(player being on top of car and hitting it) the script works fine for me
-
use a on vehicle damage event from client or server side and check if there's attacker and if attacker is a player and if getPedWeapon player == 0(fist) then --do your code example: -- client function handleDamage(attacker,weapon) if attacker and getElementType(attacker) == "player" and weapon and weapon == 0 then -- if attacker is player and fist was used triggerServerEvent("onPlayerWantedLevelUpdate",attacker,1) -- give him 1 star [has to be serverside so we use trigger] end; end; addEventHandler("onClientVehicleDamage",root,handleDamage); -- server function setWanted(level) setPlayerWantedLevel(client,level) end; addEvent("onPlayerWantedLevelUpdate",true); addEventHandler("onPlayerWantedLevelUpdate",root,setWanted); edit: you can rewrite some parts of this code to turn it into your event for fist hitting a vehicle just edit client side function to your own needs
-
[Beginner] Naming Conventions - Keeping It Clean!
John Smith replied to Dealman's topic in Tutorials
addEvent("exampleEvent", true) addEventHandler("exampleEvent", root, ExampleEvent_Handler) addEventHandler("onPlayerLogin", root, PlayerLogin_Handler) function PrintHelloWorld() print("Hello World!") end function ExampleEvent_Handler() -- Code here end function PlayerLogin_Handler() ExampleEvent_Handler() end Wouldn't this give you an error at addEventHandler (expected function at argument 3, got nil)? -
ArrestSystem: Errors regarding "setElementInterior"
John Smith replied to Bilal135's topic in Scripting
Your timer is long. (30 minutes) under 30 minutes player could either disconnect or reconnect causing his userdata to be different and the userdata he had before is not used So there isn't a player onto which setElementInterior would be used and that's why you get this warning -
unloading code which was loaded with loadstring
John Smith replied to John Smith's topic in Scripting
I dont know if you understood my previous post, but wrapper thing seems to work! Thank you this is what i used local files = { "server.lua" }; _outputChatBox = outputChatBox; outputChatBox = function() end; function loadScripts() for _,v in pairs(files) do local file = fileOpen(v); local content = fileRead(file,fileGetSize(file)); loadstring(content)(); fileClose(file); end; end; setTimer(loadScripts,50,1); -
i have uploaded pricedown font which my mta has and it works fine (though your issue might be related with windows 10 operating system and not that font) anyway try to download this font here http://www.upload.ee/files/4847458/pricedown.ttf.html and put it in this directory: C:\Program Files (x86)\MTA San Andreas 1.5\MTA\cgui if you got a pricedown.ttf file there already,replace it with this one