Jump to content

itoko

Members
  • Posts

    60
  • Joined

  • Last visited

Everything posted by itoko

  1. Ah yes, my bad, i didn't check the whole code at all, which is a big mistake ^^'. I guess the event should be onZombieWasted. (from what i know you're working on)
  2. function cbinds() bindKey("vehicle_fire", "down", cdoshoot) bindKey("vehicle_secondary_fire", "down", cdoshoot) bindKey("lctrl", "down", cdoshoot) bindKey("rctrl", "down", cdoshoot) allowShoots() end addEventHandler("onClientResourceStart", getRootElement(), cbinds) function cdoshoot(theVehicle) local theVehicle = getPedOccupiedVehicle(localPlayer) if bindTrigger == 1 then if not isPlayerDead(localPlayer) then bindTrigger = 0 local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getElementRotation(theVehicle) local x = x+4*math.cos(math.rad(rZ+90)) local y = y+4*math.sin(math.rad(rZ+90)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) setTimer(allowShoots, 4000, 1) end end end function allowShoots() bindTrigger = 1 end
  3. The conditions were kinda weird, try this: addEventHandler( "onZombieWasted", root, function ( killer, weapon, bodypart ) if killer and killer ~= source then if bodypart == 9 and weapon == 22 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ) elseif bodypart == 8 and weapon == 22 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 0.5 ) elseif bodypart == 7 and weapon == 22 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 0.5 ) elseif bodypart == 6 and weapon == 22 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 0.5 ) elseif bodypart == 5 and weapon == 22 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 0.5 ) elseif bodypart == 4 and weapon == 22 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 0.5 ) elseif bodypart == 3 and weapon == 22 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 0.5 ) end end end )
  4. Try this: function WeaponLevels (player, weapon) local Weapon = guiGetText(GUIEditor.label[2]) if Weapon then local Point = tonumber(Weapon) if Point >= 100 and weapon == 22 then guiSetText (GUIEditor.label[3],"Level: 1") end end end addEventHandler( "onClientRender",getRootElement(), WeaponLevels) because you maybe haven't 100 points, but more
  5. itoko

    Auto B

    i edited it try again
  6. yes, the level of water when it's raising is using untilW, but untilW never change, so the water level doesn't change.
  7. Sorry i forgot to edit it, i changed the target of the setPlayerMoney to the source.
  8. addEvent("buyGodMode", true) addEventHandler("buyGodMode", getRootElement(), function() if ( getPlayerMoney (source) >= 70000 ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then takePlayerMoney(source, 70000) outputChatBox("Godmode Successfully activated", source, 255, 255, 0, true) setVehicleDamageProof(getPedOccupiedVehicle(source),true) setTimer( setVehicleDamageProof, 60000, 1, getPedOccupiedVehicle(source), false) else takePlayerMoney(source, 70000) outputChatBox("Only for Admins, but you loose money for trying to buy", source, 255, 0, 0, true) end else outputChatBox("You haven't got enough money.", source, 255, 0, 0, true) end end )
  9. Maybe there is something above the serverside event, that stop the addEvent, try to put the serverside event and function you showed us, in another server file (create a new one)
  10. itoko

    Auto B

    Try this: DestructionDerby = setmetatable({}, RaceMode) DestructionDerby.__index = DestructionDerby DestructionDerby:register('Destruction derby') function DestructionDerby:isApplicable() return not RaceMode.checkpointsExist() and RaceMode.getMapOption('respawn') == 'none' end function DestructionDerby:getPlayerRank(player) return #getActivePlayers() end -- Copy of old updateRank function DestructionDerby:updateRanks() for i,player in ipairs(g_Players) do if not isPlayerFinished(player) then local rank = self:getPlayerRank(player) if not rank or rank > 0 then setElementData(player, 'race rank', rank) end end end -- Make text look good at the start if not self.running then for i,player in ipairs(g_Players) do setElementData(player, 'race rank', '' ) setElementData(player, 'checkpoint', '' ) end end end function DestructionDerby:onPlayerWasted(player) if isActivePlayer(player) then self:handleFinishActivePlayer(player) local map = exports.mapmanager:getRunningGamemodeMap() local name = getResourceInfo(map,'name') if not name:find('[DD]',1,true) then if getActivePlayerCount() <= 0 then RaceMode.endMap() else TimerManager.createTimerFor("map",player):setTimer(clientCall, 2000, 1, player, 'Spectate.start', 'auto') end else if getActivePlayerCount() <= 1 then RaceMode.endMap() else TimerManager.createTimerFor("map",player):setTimer(clientCall, 2000, 1, player, 'Spectate.start', 'auto') end end end RaceMode.setPlayerIsFinished(player) showBlipsAttachedTo(player, false) end function DestructionDerby:onPlayerQuit(player) if isActivePlayer(player) then self:handleFinishActivePlayer(player) if getActivePlayerCount() <= 1 then RaceMode.endMap() end end end function DestructionDerby:handleFinishActivePlayer(player) -- Update ranking board for player being removed if not self.rankingBoard then self.rankingBoard = RankingBoard:create() self.rankingBoard:setDirection( 'up', getActivePlayerCount() ) end local timePassed = self:getTimePassed() self.rankingBoard:add(player, timePassed) -- Do remove finishActivePlayer(player) -- Update ranking board if one player left local activePlayers = getActivePlayers() local map = exports.mapmanager:getRunningGamemodeMap() local name = getResourceInfo(map,'name') if not name:find('[DD]',1,true) then if #activePlayers == 0 then self.rankingBoard:add(activePlayers[1], timePassed) showMessage(getPlayerName(activePlayers[1]) .. ' Won This Round !!!', 30, 144, 255) end else if #activePlayers == 1 then self.rankingBoard:add(activePlayers[1], timePassed) showMessage(getPlayerName(activePlayers[1]) .. ' Won This Round !!!', 30, 144, 255) end end end ------------------------------------------------------------ -- activePlayerList stuff -- function isActivePlayer( player ) return table.find( g_CurrentRaceMode.activePlayerList, player ) end function addActivePlayer( player ) table.insertUnique( g_CurrentRaceMode.activePlayerList, player ) end function removeActivePlayer( player ) table.removevalue( g_CurrentRaceMode.activePlayerList, player ) end function finishActivePlayer( player ) table.removevalue( g_CurrentRaceMode.activePlayerList, player ) table.insertUnique( g_CurrentRaceMode.finishedPlayerList, _getPlayerName(player) ) end function getFinishedPlayerCount() return #g_CurrentRaceMode.finishedPlayerList end function getActivePlayerCount() return #g_CurrentRaceMode.activePlayerList end function getActivePlayers() return g_CurrentRaceMode.activePlayerList end
  11. function money() setPlayerMoney( source, 0 ) end addEventHandler("onPlayerLogout",getRootElement(),money) Well, that depend of your script that save the money, normally yes.
  12. I guess this is what you're looking for: dxSetAspectRatioAdjustmentEnabled() https://wiki.multitheftauto.com/wiki/Dx ... entEnabled
  13. If you just want it in the corner, then don't use screen size. function Next() local x, y = guiGetScreenSize () tx = 0 ty = 10 dxDrawRectangle ( tx, ty, 130, 20, tocolor ( 0, 0, 0, 200 ) ) dxDrawColorText ("Next", tx+3, ty, tx, ty, tocolor(255,255,255,255), 1.3, "default-bold","nil","nil") end addEventHandler("onClientRender",getRootElement(),Next) But you can also make the positions relative. (divide your position by the screensize ==> tx/x ty/y and then replace the pics)
  14. You can edit the race gamemode itself, in the race_server.lua file, replace the manual spectate request function, that should be enough, i haven't tested but give it a try: -- Handle client request for manual spectate addEvent('onClientRequestSpectate', true) addEventHandler('onClientRequestSpectate', g_Root, function(enable) if checkClient( false, source, 'onClientRequestSpectate' ) then return end -- Checks if switching on local player = source if enable then if not stateAllowsManualSpectate() then return end if not _TESTING then -- if isPlayerInACLGroup(player, g_GameOptions.admingroup) then if not RaceMode.isMapRespawn() and g_GameOptions.norsadminspectate then return false end -- else -- if not RaceMode.isMapRespawn() or not g_GameOptions.anyonecanspec then -- return false -- end -- end end end if isPlayerSpectating(player) ~= enable then if enable then clientCall(player, "Spectate.start", 'manual' ) if not g_GameOptions.stealthspectate or not isPlayerInACLGroup(player, g_GameOptions.admingroup) then setPlayerStatus( player, nil, "spectating") end Override.setCollideOthers( "ForSpectating", RaceMode.getPlayerVehicle( player ), 0 ) g_SavedVelocity[player] = {} g_SavedVelocity[player].velocity = {getElementVelocity(g_Vehicles[player])} g_SavedVelocity[player].turnvelocity = {getVehicleTurnVelocity(g_Vehicles[player])} else clientCall(player, "Spectate.stop", 'manual' ) setPlayerStatus( player, nil, "") Override.setCollideOthers( "ForSpectating", RaceMode.getPlayerVehicle( player ), nil ) if g_GameOptions.racerespawn and RaceMode.getNumberOfCheckpoints() > 0 then -- Do respawn style restore restorePlayer( g_CurrentRaceMode.id, player, true, true ) else -- Do 'freeze/collision off' stuff when stopping spectate RaceMode.playerFreeze(player, true, true) TimerManager.createTimerFor("map",player):setTimer(afterSpectatePlayerUnfreeze, 2000, 1, player, true) end end end end ) The commented lines are the conditions for to use the function, you easily edit it for a certain usergroup too, look on the wiki for the isPlayerInACLGroup function.
  15. itoko

    Question

    That should be enough: function main ( ) start = getTickCount() addEventHandler ("onClientRender", root, move) end bindKey ("F2","down", main) function move ( ) if not dxgui then local x = 0.5 local y = 0.5 local w = 0.6 local h = 0.6 local now = getTickCount() local elapsedTime = now - start local endtime = start + 1000 local duration = endtime - start local progress = elapsedTime / duration local w1, h1, z = interpolateBetween ( 0, 0, 0, w, h, 0, progress, "OutInBounce") x1 = x-(w1/2) y1 = y-(h1/2) local dxgui = guidxCreateWindow(x1,y1,w1, h1,"SHOP PANEL",70) end end
  16. At line 32 you put a coma instead of two points after source, and at line 382 you forgot to put the element before the color: -- -- toptimes_server.lua -- SToptimesManager = {} SToptimesManager.__index = SToptimesManager SToptimesManager.instances = {} --------------------------------------------------------------------------- -- Server -- Handle events from Race -- -- This is the 'interface' from Race -- --------------------------------------------------------------------------- addEvent('onMapStarting') addEventHandler('onMapStarting', g_Root, function(mapInfo, mapOptions, gameOptions) if g_SToptimesManager then g_SToptimesManager:setModeAndMap( mapInfo.modename, mapInfo.name, gameOptions.statsKey ) end end ) addEvent('onPlayerPickUpRacePickup') addEventHandler('onPlayerPickUpRacePickup', g_Root, function(number, sort, model) if sort == "vehiclechange" then if model == 425 then outputChatBox ( source.."has got the Hunter", getRootElement(), 255, 255, 255, true ) if g_SToptimesManager then g_SToptimesManager:playerFinished( source, exports.race:getTimePassed()) end end end end ) addEvent('onPlayerFinish') addEventHandler('onPlayerFinish', g_Root, function(rank, time) if g_SToptimesManager then g_SToptimesManager:playerFinished( source, time) end end ) addEventHandler('onResourceStop', g_ResRoot, function() if g_SToptimesManager then g_SToptimesManager:unloadingMap() end end ) addEventHandler('onPlayerQuit', g_Root, function() if g_SToptimesManager then g_SToptimesManager:removePlayerFromUpdateList(source) g_SToptimesManager:unqueueUpdate(source) end end ) addEventHandler('onResourceStart', g_ResRoot, function() local raceInfo = getRaceInfo() if raceInfo and g_SToptimesManager then g_SToptimesManager:setModeAndMap( raceInfo.mapInfo.modename, raceInfo.mapInfo.name, raceInfo.gameOptions.statsKey ) end end ) function getRaceInfo() local raceResRoot = getResourceRootElement( getResourceFromName( "race" ) ) return raceResRoot and getElementData( raceResRoot, "info" ) end --------------------------------------------------------------------------- -- -- Events fired from here -- --------------------------------------------------------------------------- addEvent("onPlayerToptimeImprovement") --------------------------------------------------------------------------- --------------------------------------------------------------------------- -- -- SToptimesManager:create() -- -- Create a SToptimesManager instance -- --------------------------------------------------------------------------- function SToptimesManager:create() local id = #SToptimesManager.instances + 1 SToptimesManager.instances[id] = setmetatable( { id = id, playersWhoWantUpdates = {}, updateQueue = {}, serviceQueueTimer = nil, displayTopCount = 12, -- Top number of times to display mapTimes = nil, -- SMaptimes:create() serverRevision = 0, -- To prevent redundant updating to clients }, self ) SToptimesManager.instances[id]:postCreate() return SToptimesManager.instances[id] end --------------------------------------------------------------------------- -- -- SToptimesManager:destroy() -- -- Destroy a SToptimesManager instance -- --------------------------------------------------------------------------- function SToptimesManager:destroy() SToptimesManager.instances[self.id] = nil self.id = 0 end --------------------------------------------------------------------------- -- -- SToptimesManager:postCreate() -- -- -- --------------------------------------------------------------------------- function SToptimesManager:postCreate() cacheSettings() self.displayTopCount = g_Settings.numtimes end --------------------------------------------------------------------------- -- -- SToptimesManager:setModeAndMap() -- -- Called when a new map has been loaded -- --------------------------------------------------------------------------- function SToptimesManager:setModeAndMap( raceModeName, mapName, statsKey ) outputDebug( 'TOPTIMES', 'SToptimesManager:setModeAndMap ' .. raceModeName .. '<>' .. mapName ) -- Reset updatings from the previous map self.playersWhoWantUpdates = {} self.updateQueue = {} if self.serviceQueueTimer then killTimer(self.serviceQueueTimer) end self.serviceQueueTimer = nil -- Remove old map times if self.mapTimes then self.mapTimes:flush() -- Ensure last stuff is saved self.mapTimes:destroy() end -- Get map times for this map self.mapTimes = SMaptimes:create( raceModeName, mapName, statsKey ) self.mapTimes:load() -- Get the toptimes data ready to send self:updateTopText() end --------------------------------------------------------------------------- -- -- SToptimesManager:unloadingMap() -- -- Called when unloading -- --------------------------------------------------------------------------- function SToptimesManager:unloadingMap() if self.mapTimes then self.mapTimes:flush() -- Ensure last stuff is saved end end --------------------------------------------------------------------------- -- -- SToptimesManager:playerFinished() -- -- If time is good enough, insert into database -- --------------------------------------------------------------------------- function SToptimesManager:playerFinished( player, newTime, dateRecorded ) -- Check if top time recording is disabled for this player if getElementData ( player, "toptimes" ) == "off" then return end if not self.mapTimes then outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) return end dateRecorded = dateRecorded or getRealDateTimeNowString() local oldTime = self.mapTimes:getTimeForPlayer( player ) -- Can be false if no previous time local newPos = self.mapTimes:getPositionForTime( newTime, dateRecorded ) -- See if time is an improvement for this player if not oldTime or newTime < oldTime then local oldPos = self.mapTimes:getIndexForPlayer( player ) triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) -- See if its in the top display if newPos <= self.displayTopCount then outputDebug( 'TOPTIMES', getPlayerName(player) .. ' got toptime position ' .. newPos ) end if oldTime then outputDebug( 'TOPTIMES', getPlayerName(player) .. ' new personal best ' .. newTime .. ' ' .. oldTime - newTime ) end self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) -- updateTopText if database was changed if newPos <= self.displayTopCount then self:updateTopText() end end outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) end --------------------------------------------------------------------------- -- -- SToptimesManager:updateTopText() -- -- Update the toptimes client data for the current map -- --------------------------------------------------------------------------- function SToptimesManager:updateTopText() if not self.mapTimes then return end -- Update data
  17. Ah right, little mistake i edited it
  18. Here you go: local theSerial = "" -- put the serial of the player local theCar = 411 -- put the ID of the car function randomVehColors() for _,player in ipairs(getElementsByType("player")) do if getPlayerSerial(player) == theSerial then if isPedInVehicle(player) then local car = getPedOccupiedVehicle(player) if getElementModel(car) == theCar then local color = {} color[1] = math.random(0,126) color[2] = math.random(0,126) color[3] = math.random(0,126) color[4] = math.random(0,126) setVehicleColor ( car, color[1], color[2], color[3], color[4] ) end end end end end setTimer( randomVehColors, 500, 0 )
  19. Hope that's what you asked for: local theSerial = "putyourserialhere" function randomVehColors() for _,player in ipairs(getElementsByType("player")) do if getPlayerSerial(player) == theSerial then if isPedInVehicle(player) then local car = getPedOccupiedVehicle(player) local color = {} color[1] = math.random(0,126) color[2] = math.random(0,126) color[3] = math.random(0,126) color[4] = math.random(0,126) setVehicleColor ( car, color[1], color[2], color[3], color[4] ) end end end end setTimer( randomVehColors, 500, 0 )
  20. Just add that: addEventHandler("onClientRender",getRootElement(),text_render) at the end of this: local messages = { ["¿Que? Señor?"] = { 0, 0, 3 }, ["No hablas Español, hablas Inglés."] = { 10, 0, 3 }, ["Je ne parle pas français, je parle Néerlandais."] = { 20, 0, 3 } } function text_render ( ) for i,v in pairs ( messages ) do local x, y, z = unpack ( v ) local sx, sy, _ = getScreenFromWorldPosition ( x, y, z ) if sx then dxDrawText ( i, sx, sy, sw, sh, tocolor ( 255, 200, 0, 255 ), 1.0, "default-bold" ) end end end There are no event to run the function.
  21. I checked the admin resource, and the commands are not finished yet, so there is none.
  22. Well, that is wrong: (line 59) local tieneUZI = getPedWeapon(source,5) the slot 5 is for assault rifles, and the UZI is a submachine gun, just change it to 4. local tieneUZI = getPedWeapon(source,4) Here you got the weapons and their slots: https://wiki.multitheftauto.com/wiki/Weapon
×
×
  • Create New...