-
Posts
6,089 -
Joined
-
Last visited
-
Days Won
216
Everything posted by IIYAMA
-
Can you continuous my addCommandHandler example, so I know how I can use the account name as key for the sql table?
-
This is my first try to create a SQL database. local possibleData = { "serial TEXT", "playerName TEXT" } -- This is for creating the .db file? local resultOfExecuteSQLQuery = executeSQLQuery("CREATE TABLE IF NOT EXİSTS player ( " .. table.concat(possibleData,", ") .. ")") outputDebugString(tostring(resultOfExecuteSQLQuery)) addCommandHandler("test", function (player) local account getPlayerAccount(player) if not isGuestAccount (account) then local accountName = getAccountName(account) local serial = getPlayerSerial(player) local playerName = getPlayerName(player) -- todo -- end end) Yet I do not understand how to add players.
-
If you did read this post: viewtopic.php?f=91&t=47897 You would have known what the purpose of the scripting section is and where to post request posts. Good luck. Put requests for scripts on the resource section.
-
Nope, Most scripters truly hate begging people like you. Also pls go to the right section, they will come to you there.
-
Afaik using https://wiki.multitheftauto.com/wiki/LoadMapData will load faster and probably using less cpu. The more mta functions you require, the slower the code. But I haven't test the speed of the loadMapData function yet, so I can't really say how much faster it is. This function will also be called behind the scenes when you start a resource which includes in the meta.xml a .map file. When you do not include this file in the meta.xml, you can start it manually using the loadMapData function. Afaik the only reason why people started using clientside maps, is because your can use the function https://wiki.multitheftauto.com/wiki/Tr ... lientEvent This function will make it possible to show a custom download bar. (which indicates how long it takes before the map is downloaded)
-
It has one purpose, saving space on your server. Since mta copies everything that is running in the cache folder, you will lose space anyway. Space using: 334(cache unzipped) + 150(resource folder) = 484 mb -- zipped 334(cache unzipped) + 334(resource folder) = 668 mb -- not zipped This example doesn't tell you anything extra, except it can make your HDD faster in search results. Because they don't consider it as priority, it is sad I know...
-
He means that clientside code is running on the players their pc, so it is edit able. Yet, I haven't seen any hackers successfully do anything with it. But: Using onPlayerWasted serverside would be more effective because it uses less bandwidth.
-
It is flashing because of your counter part... local pissBarStatus = false function showBar() pissBarStatus = not pissBarStatus end addEvent("onClientShowBar",true) addEventHandler("onClientShowBar", root, showBar) addCommandHandler("piss", showBar) local sx,sy = guiGetScreenSize () local barx = sx/800*683 local bary = sy/600*89 local barxoverlay = sx/800*685 local baryoverlay = sy/600*91 local barName = "PISS" addEventHandler("onClientRender",root, function () if pissBarStatus then local barRelative = math.max(math.min(tonumber(getElementData(localPlayer, "piss")) or 0,100),0)/100 dxDrawText ( barName, barx/0.499 + 1, bary/0.492, 76, 12, tocolor ( 255, 255, 255, 255 ), 1, "default", "center", "center", false, false, true ) dxDrawRectangle (barx, bary, 80, 14, tocolor (0,0,0,255), false) dxDrawRectangle (barxoverlay-0.5, baryoverlay-0.8, 77, 10, tocolor (235,141,45,127), false) dxDrawRectangle (barxoverlay-0.5, baryoverlay-0.8, 75.5*barRelative, 10, tocolor (235,141,45,185), false) end end)
-
and what is the counter for? Well if that is what you want, you don't need all that code. local pissBarStatus = false function showBar() pissBarStatus = not pissBarStatus end addEvent("onClientShowBar",true) addEventHandler("onClientShowBar", root, showBar) addCommandHandler("piss", showBar) local sx,sy = guiGetScreenSize () local barx = sx/800*683 local bary = sy/600*89 local barxoverlay = sx/800*685 local baryoverlay = sy/600*91 local barName = "PISS" local counter = 0 addEventHandler("onClientRender",root, function () if pissBarStatus then local barRelative = math.max(math.min(tonumber(getElementData(localPlayer, "piss")) or 0,100),0)/100 if (counter > 25) then dxDrawText ( barName, barx/0.499 + 1, bary/0.492, 76, 12, tocolor ( 255, 255, 255, 255 ), 1, "default", "center", "center", false, false, true ) dxDrawRectangle (barx, bary, 80, 14, tocolor (0,0,0,255), false) dxDrawRectangle (barxoverlay-0.5, baryoverlay-0.8, 77, 10, tocolor (235,141,45,127), false) dxDrawRectangle (barxoverlay-0.5, baryoverlay-0.8, 75.5*barRelative, 10, tocolor (235,141,45,185), false) counter = counter +1 else counter = counter +1 end if (counter >= 50) then counter = 0 end end end)
-
That is right, since there are no comments of your own in the code I do not know what the code should do. You are adding bars in to a all in one bar manage system, it is still unclear what your end result must be.
-
Updated, previous post. > local values = listBRS[i]
-
function showBar(barx, bary, barxoverlay, baryoverlay, barRelative, counter, barName) return table.insert(listBRS, {barx, bary, barxoverlay, baryoverlay, barRelative, counter, barName}) end addEvent("onClientShowBar",true) addEventHandler("onClientShowBar", root, showBar) function renderBar() if (#listBRS > 0) then --for i, values in ipairs(listBRS) do for i=#listBRS,1, -1 do -- make sure you can remove items properly. (using table.remove) This is only possible when you inverse your loop. local values = listBRS[i] -- first make sure you know at which array your variables are. local barx, bary, barxoverlay, baryoverlay, barRelative, counter, barName = values[1], -- barx values[2], -- bary values[3], -- barxoverlay values[4], -- baryoverlay values[5], -- barRelative values[6], -- counter = at array 6 << very important. values[7] -- barName if (counter > 25) then dxDrawText ( barName, barx/0.499 + 1, bary/0.492, 76, 12, tocolor ( 255, 255, 255, 255 ), 1, "default", "center", "center", false, false, true ) dxDrawRectangle (barx, bary, 80, 14, tocolor (0,0,0,255), false) dxDrawRectangle (barxoverlay-0.5, baryoverlay-0.8, 77, 10, tocolor (235,141,45,127), false) dxDrawRectangle (barxoverlay-0.5, baryoverlay-0.8, 75.5*barRelative, 10, tocolor (235,141,45,185), false) counter = counter +1 else counter = counter +1 end values[6] = counter -- now save the edited variable counter back at array 6 if (counter >= 50) then --counter = 0 --(Don't you need to remove that item?) table.remove(listBRS,i) -- removed! end end end end addEventHandler("onClientRender",getRootElement(),renderBar) function :~() local sx,sy = guiGetScreenSize () local x = sx/800*683 local y = sy/600*89 local x1 = sx/800*685 local y1 = sy/600*91 -- Making sure the value is always correct. (between 0 t/m 100) Never trust element data, since all resources can edit it. local pissData = math.max(math.min(tonumber(getElementData(getLocalPlayer(), "piss")) or 0,100),0)/100 -------------------- local pissBar = 100 local title = "PISS" showBar(x, y, x1, y1, pissData, pissBar, title) end addCommandHandler("piss", :~)
-
Post full code, I can't find the problem in this part.
-
You could try something like this: (NOT TESTED) local calculateProgress = function (timeNow,futureTime, startValue,endValue,duration) local timeNow = timeNow or getTickCount() if timeNow < futureTime then if startValue > endValue then local factor = 1-(futureTime-timeNow)/duration return ((startValue-endValue)* factor) + endValue elseif startValue < endValue then local factor = ((futureTime-timeNow)/duration) return ((endValue-startValue)* factor) + startValue else -- remember you can't do 0/number, so... return startValue end else return endValue end end local futureTime = getTickCount()+500 addEventHandler("onClientRender",root, function () dxDrawText(tostring(calculateProgress(getTickCount(),futureTime,1,10,500)),300,300) end) Make sure that the futureTime-startTime matches the duration.
-
This is not a request!!! Custom onClientPlayerWeaponSwitch event which will now trigger for all players, instead only for the localPlayer. Use it like you want... So: [b]Source[/b] The source of this event is the player who changed his weapon. [strike](Local player only)[/strike] Example: addEventHandler ( "onClientPlayerWeaponSwitch",root, function ( prevSlot, newSlot, custom) outputDebugString (prevSlot .. ", " .. newSlot .. " " .. tostring(custom)) end) Source code. local playerDataBase = {} addEventHandler("onClientResourceStart",resourceRoot, function () local allPlayers = getElementsByType("player") for i=1,#allPlayers do local player = allPlayers[i] if player ~= localPlayer then local slot = getPedWeaponSlot ( player ) playerDataBase[player] = slot end end end) addEventHandler("onClientPlayerJoin",root, function () playerDataBase[source] = getPedWeaponSlot (source) end) addEventHandler("onClientRender",root, function () for player,oldSlot in pairs(playerDataBase) do if isElement(player) then local newSlot = getPedWeaponSlot ( player ) if oldSlot ~= newSlot then triggerEvent("onClientPlayerWeaponSwitch",player,oldSlot,newSlot,true) playerDataBase[player] = newSlot end else playerDataBase[player] = nil end end end)
-
= "what ever" .. nil setVehicleColor(kar, tonumber(a) or 0,tonumber(b) or 0,tonumber(c) or 0) Do you see here .. ?????? I don't think so...
-
function consoleSetPlayerGravity ( player, commandName, level ) if ( player ) then local money = getPlayerMoney(player) if money >= 15000 then local success = setPedGravity ( player, tonumber ( 0.0055 ) ) if (not success) then outputConsole( "Failed to set player gravity", player ) else -- success! outputChatBox("Weed is now Activated (it will auto Disabled when you Disconnect)",player, 255, 171, 0) takePlayerMoney ( player, 15000) end else -- not enought money outputChatBox("You dont have enough of money to use weed", player, 255, 0, 0) end end end addCommandHandler ( "sb", consoleSetPlayerGravity )
-
You must be kidding me... Why don't you try it first yourself? If it is wrong I will correct you.
-
local money = getPlayerMoney(player) if money >= 50000 then else-- not enough money outputChatBox("......",player) end
-
np. I hope you learned something from it.
-
See my last post.
-
addCommandHandler ( "setplayergravity", setPlayerGravity ) addCommandHandler ( "setplayergravity", consoleSetPlayerGravity )
-
Is the system working per player or global? This is per player: local damageProofPlayers = {} function random1(playerSource) damageProofPlayers[playerSource] = true local vehicle = getPedOccupiedVehicle(playerSource) if vehicle then setVehicleDamageProof(vehicle,true) end end function random2(playerSource) damageProofPlayers[playerSource] = nil local vehicle = getPedOccupiedVehicle(playerSource) if vehicle then setVehicleDamageProof(vehicle,false) end end addEventHandler("onPlayerQuit",root, -- clean memory function () if damageProofPlayers[source] then damageProofPlayers[source] = nil end end) function vehicleEntry (playerSource) if damageProofPlayers[playerSource] then setVehicleDamageProof(source,true) end addEventHandler ("onVehicleEnter", root, vehicleEntry)
-
function carGodMode(vehicle,playerSource) ---i have my functions here which i cant post -- example = if true then return true end return false ------------ end function carNoGodMode(vehicle,playerSource) ---i have my functions here which i cant post -- example = if true then return true end return false ------------ end function vehicleEntry (playerSource) if carGodMode(source,playerSource) then setVehicleDamageProof(source,true) elseif carNoGodMode(source,playerSource) then setVehicleDamageProof(source,false) end end addEventHandler ("onVehicleEnter", root, vehicleEntry)
-
You can try something like this, edit it like you want. client local connectionOverFlowLimiter = 0 local validBodyParts = {[5]=true,[6]=true} addEventHandler ( "onClientPlayerDamage",localPlayer, function (attacker, weapon, bodypart) if attacker and attacker ~= localPlayer then -- optional if not validBodyParts[bodypart] then cancelEvent() else local newHealth = getElementHealth(localPlayer)-50 if newHealth > 0 then setElementHealth(localPlayer,newHealth) elseif getTickCount() > connectionOverFlowLimiter then -- recommendation. triggerServerEvent("onCustomPlayerWasted",localPlayer,attacker, weapon, bodypart) connectionOverFlowLimiter = getTickCount()+50-- time now + 50 ms toggleAllControls (false,false,true) end end end end) addEventHandler("onClientPlayerSpawn",localPlayer, function () toggleAllControls (true,true,true) end) server addEvent("onCustomPlayerWasted",true) addEventHandler("onCustomPlayerWasted",root, function (attacker,weapon,bodyPart) if client == source and isElement(source) then killPed(source,attacker,weapon,bodyPart) end end)
