-
Posts
6,063 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
If you can't find the problem, you have to debug the script. I am saying that for years..... png = guiCreateStaticImage(0.311, 0.454, 0.349, 0.626, "target.png", true) guiSetVisible(png , false) if not isElement(png) then outputChatBox("no png...") end addEventHandler( "onClientPlayerTarget", root, function( target ) outputChatBox("target changed localPlayer") if ( getPedWeapon( localPlayer ) == 29 ) then outputChatBox("localPlayer has mp5") if ( target ) then outputChatBox("show png)" guiSetVisible(png, true) else outputChatBox("hide png") guiSetVisible(png, false) end end end)
-
Just as DNL291 said. local thisVehicle = getElementData (source, "car") if isElement(thisVehicle) and #getVehicleOccupants(thisVehicle) ~= 0 then
-
ups The data inside the table upgrades. Try something like this: (not tested) local mergeUpgrades = function (myTable,upgrades) if type(upgrades)== "table" and #upgrades > 0 then for i=1,#upgrades do local result = true local upgrade = upgrades[i] for j=1,#myTable do if myTable[j]== upgrade then result = false break end end if result then myTable[#myTable+1]= upgrade end end end return myTable end addEvent( "modShop_playerLeaveModShop", true ) addEventHandler( "modShop_playerLeaveModShop", getRootElement( ), function( vehicle, itemsCost, upgrades, colors, paintjob, shopName ) local pMoney = getPlayerMoney( source ) local account = getPlayerAccount(source) if pMoney >= itemsCost and account then modTheVehicle( vehicle, upgrades, colors, paintjob, shopName ) takePlayerMoney( source, itemsCost ) triggerClientEvent( source, "modShop_moddingConfirmed", source ) local data = getAccountData (getPlayerAccount(source), "cu") local myTable = mergeUpgrades(data and fromJSON ( data ) or {},upgrades) setAccountData (account, "cu",toJSON (myTable)) else outputChatBox( "#FF0000Inufficient founds! #00FF00Your pocket shows $"..tostring( getPlayerMoney( source ) )..".#FFFFFF Uninstall some upgrades.", source, 0,0,0,true) end end)
-
unpack does this: local data1,data2,data3 = unpack({"A","B","C"}) outputChatbox(data1 .. " " .. data2 .. " " .. data3) -- A B C
-
toJSON is before you save it. local myTable = {} setAccountData (getPlayerAccount(source), "cu",toJSON (myTable)) fromJSON is when you load it. local data = getAccountData (getPlayerAccount(source), "cu") if data then local u = fromJSON ( data ) end and no I have never used this(JSON) before.
-
Don't try to help him when you don't know what he is talking about.
-
u isn't a table. getAccountData (getPlayerAccount(source), "cu") --< convert first to tojson: https://wiki.multitheftauto.com/wiki/ToJSON -- save setAccountData -- load getAccountData https://wiki.multitheftauto.com/wiki/FromJSON convert fromJSON
-
It is important, but not everybody wants to learn lua else he would ask for the tables.
-
What is the limit of peds on the server to not have LAG?
IIYAMA replied to ronaldoguedess's topic in Scripting
Bandwidth is the problem. You can only stop some of the lagg by saving it. -
True, but for him it isn't important at the moment.
-
You can, unless it is destroyed. local car=getElementData(source, "car") if isElement(car) then -- check if it still does exist. destroyElement(car) end
-
local lastTime = 0 addEventHandler("onClientRender", root, function() local timeNow = getTickCount() if timeNow > lastTime then local health = getElementHealth( localPlayer ) if health > 0 and health < 100 then local newHealth = health+1 setElementHealth(localPlayer,newHealth < 100 and newHealth or 100) end lastTime = timeNow+1000 end end) Or you set a timer or you use onClientRender with tickCount, but not both. The benefit of onClientRender is that you can render it directly at your screen with dx functions.
-
That will lagg. If you set the value again don't expect it won't use bandwidth. (because elementdata can also be set on client side without syncronisation, so it will set it again and again) setTimer(function() for index, players in pairs(getElementsByType("player")) do local playerMoney = "$"..getPlayerMoney(players) local lastPlayerMoney = getElementData(players,"Money") if not lastPlayerMoney or lastPlayerMoney ~= playerMoney then setElementData(players, "Money",playerMoney) end local x, y, z = getElementPosition(players) local playerZoneName = getZoneName(x, y, z, true) local lastPlayerZoneName = getElementData(players,"City") if not lastPlayerZoneName or lastPlayerZoneName ~= playerZoneName then setElementData(players, "City",playerZoneName) end end end, 1000, 0)
-
It should be here: function addMutedPlayer(thePlayer, cmd, Target, time) if hasObjectPermissionTo(thePlayer, "command.mute") then for i,v in ipairs(getElementsByType("player")) do local playername0 = string.gsub(getPlayerName(v), "#%x%x%x%x%x%x", "") local playername1 = string.lower(playername0) if string.match(playername1, Target) then local serialA = getPlayerName(thePlayer) local serialB = getPlayerSerial(v) MutedPlayers[serialB] = serialA if time then MutedTime = time * 1000 MutedPlayer[thePlayer] = setTimer(function() MutedPlayers[SerialB] = nil end, MutedTime, 1) outputChatBox("#00aaff[AntiSpam]: Player ".. getPlayerName(v) .."#00aaff was muted by ".. getPlayerName(thePlayer), getRootElement(), 255,255,255,true) outputChatBox("#00aaff[AntiSpam]: Mute Time: #00aaff ".. string.format ( '%02d:%02d', math.floor(MutedTime/60/1000), math.fmod(math.floor(MutedTime/1000),60)), getRootElement(), 255,255,255,true) else outputChatBox("#00aaff[AntiSpam]: Player ".. getPlayerName(v) .."#00aaff was muted by ".. getPlayerName(thePlayer), getRootElement(), 255,255,255,true) end break else outputChatBox("#00aaff[AntiSpam]: Player Could not be found!", thePlayer, 255,255,255,true) end end else return outputChatBox("#00aaff[AntiSpam]: You cant use this!", thePlayer, 255,255,255,true) end end addCommandHandler("mp", addMutedPlayer, false,false)
-
Damn, you guys are fast in posting. local object = createObject ( 1337, 0, 0, 0, 0, 0, 0 ) setElementCollidableWith ( localPlayer, object,false) addEventHandler("onClientPreRender",root, function () local xr,yr,zr = getElementRotation(localPlayer) local x,y,z = getPedBonePosition (localPlayer,8 ) setElementPosition(object,x,y,z) setElementRotation(object,xr,yr,zr) end)
-
Well the break should be there after it found it's target. Only you have out it in the wrong block. Should be in the 4th block. function () --block 1 if --block 2 for .... loop... --block 3 if true then -- fount target condition... --block 4 break end end end end
-
It's possible. Not with MTA Functions, but with LUA functions. Lua functions can't do anything with object's except saving their userdata's, nothing more nothing less. While MTA functions, can change things ingame..... Pls don't talk crap.
-
why don't you output both the names and find your problem... Those bugs can be found when you are debugging, when you don't do that it will cost 10 times more time to find it.
-
if you debug your script for every step you take, you hardly can make mistakes. It is learning from your mistakes, retry, debug again till you got the problem. You can't fix a problem caused by a problem when you don't see it.
-
well debug it..... > outputChatBox That is the best way to solve it.
-
local tex, mod = getPedClothes(player, tonumber(clothesType))
-
You forgot to convert world position to screenposition. https://wiki.multitheftauto.com/wiki/Ge ... ldPosition
-
Also: local cars = { {602}, {600}, {587}, {603}, -- etc --Too: local cars = { 602, 600, 587, 603, --ect
-
function saveSkin(player,clothesType) local account = getPlayerAccount(player) if not isGuestAccount(account) and getElementModel(player) == 0 and clothesType then for i, data in ipairs(playerDataTable) do local tex, mod = getPedClothes(player, clothesType) if tex and mod then setAccountData(account, data, tex..",".. mod .. "," .. clothesType) --outputChatBox("saved #"..i..": "..getAccountData(account, data[1])) else outputChatBox("no tex and mod") end end end end addCommandHandler("s", saveSkin) /s 0 function loadSkin(player) local account = getPlayerAccount(player) if not isGuestAccount(account) and getElementModel(player) == 0 then for i, data in ipairs(playerDataTable) do local clothing = getAccountData(account, data) if clothing then local table = split(clothing,",") if table then outputChatBox(tostring(table[1]) .. " " .. tostring(table[2]) .. " " .. tostring(table[3])) addPedClothes (player,table[1] , table[2],tonumber(table[3])) end end --outputChatBox("saved #"..i..": "..getAccountData(account, data[1])) end end end addCommandHandler("x", loadSkin) Well debug it. Sorry (can't use tabs because I am running mac at the moment)