Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. IIYAMA

    Dead Peds

    You sure all peds are serverside? As far I know they are all always destroy able. I have build something similar to slotboth and I never had any problems with it. How do you save those peds? Because holding the registration at moment of creation is the best way to destroy them all without any problems. Also getElementHealth returns better information if a ped is dead then isPedDead. (depends if you are freezing your peds or disable their col)
  2. First of all: you made a typo: "OnPlayerSpawn" . "onPlayerSpawn"
  3. IIYAMA

    Help fix bugs

    Try something like this. local aim = guiCreateStaticImage(0.311, 0.454, 0.349, 0.626, "aim.png", true) guiSetVisible(aim, false) local convertButtonState={["down"]=true,["up"]=false} bindKey ("aim_weapon","both", function(key,state) guiSetVisible( aim, convertButtonState[state] ) end)
  4. "selection"
  5. Simply because it uses more memory. The easy way isn't always the best way. Even so, his version can get bugged, while yours can't. So the best result will be: onVehicleEnter + render check if he is in the vehicle else remove the handler. A combination would be the best.
  6. oh wait. I also played in DDC under the nick Alex-Rider. (not any more)
  7. I saw your nick inside a stealth server. (probably GCC or gta.ru) Are you German?
  8. np. P.s: didn't we ever met in game? (I remember somebody with that nick)
  9. function kill(p) if p and isElement(p) and getElementType(p) == "player" then source = p end -- here was your bug. unbindKey(source, "enter", "down", "suicide") if isPedDead(source) == false then killPed(source) if getElementType(source) ~= "player" then destroyElement(source)-- you can't destroy players end end local vehicle = playerVehicle[source] if isElement(vehicle) then setTimer(destroyPlayerVehicle, 5000, 1, vehicle) end end addEventHandler("onPlayerQuit", root, kill) addCommandHandler("suicide", kill) addEvent("onRequestKillPlayer", true) addEventHandler("onRequestKillPlayer", root, kill) function destroyPlayerVehicle(vehicle) if isElement(vehicle) then destroyElement(vehicle) end end -- the big bad bug -- (BBB) --[[onPlayerQuit Serverside event This event is triggered when a player disconnects from the server. Parameters string quitType, string reason, element responsibleElement]] <<<<<<<<<<<<<<
  10. IIYAMA

    tables

    np.
  11. 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)
  12. Just as DNL291 said. local thisVehicle = getElementData (source, "car") if isElement(thisVehicle) and #getVehicleOccupants(thisVehicle) ~= 0 then
  13. IIYAMA

    tables

    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)
  14. IIYAMA

    tables

    unpack does this: local data1,data2,data3 = unpack({"A","B","C"}) outputChatbox(data1 .. " " .. data2 .. " " .. data3) -- A B C
  15. IIYAMA

    tables

    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.
  16. IIYAMA

    tables

    Don't try to help him when you don't know what he is talking about.
  17. IIYAMA

    tables

    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
  18. It is important, but not everybody wants to learn lua else he would ask for the tables.
  19. Bandwidth is the problem. You can only stop some of the lagg by saving it.
  20. True, but for him it isn't important at the moment.
  21. You can, unless it is destroyed. local car=getElementData(source, "car") if isElement(car) then -- check if it still does exist. destroyElement(car) end
  22. IIYAMA

    Render health

    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.
  23. 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)
  24. IIYAMA

    Custom Mute

    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)
  25. 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)
×
×
  • Create New...