Jump to content

kewizzle

Members
  • Posts

    165
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by kewizzle

  1. Client.lua heres my script local speaker = createObject(2232, -657.90002441406, 944.90002441406, 12, 0, 0, 255) local url = "http://208.85.242.69:9622/listen.pls" function playMusic(button) if (button) == "left" then local sound = playSound3D(url, -657.90002441406, 944.90002441406, 12) else stopSound(sound) end end addEventHandler( "onClientClick", speaker, playMusic )
  2. i got it working! outputServerLog ( "***Spawn Script Loaded ***" ) local PlayersTeam = createTeam ( "Players" ) setTeamFriendlyFire ( PlayersTeam, false ) local spawnX, spawnY, spawnZ = math.random(-694,-679), math.random(951,963), 15 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) setPlayerTeam(source, PlayersTeam ) outputChatBox("#FF00DC"..getPlayerName(source).." #ff0000Welcome To K#ff4000e#ff7f00w#ffbf00i#ffff00z#00ff00z#00ff80l#00ffffe#0080ff'#0000ffs Zombie Server, :O :O. Press \"F9\" For HELP", source, r, g, b, true) end addEventHandler ( "onPlayerLogin", getRootElement(), joinHandler ) function deathHandler() setTimer( function(source) spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) getammo = getPedTotalAmmo ( source, 2 ) if (getammo <= 14) then giveWeapon ( source, 22, 15 ) end end,1000,1,source) end addEventHandler("onPlayerWasted", getRootElement(), deathHandler) thanks all!
  3. it works but my player doesnt spawn with a colt 45 when ammo is below 15. ill add this to on player spawn and let you know if it works EDIT: it did not. getammo = getPedTotalAmmo ( source, 2 ) if (getammo <= 14) then giveWeapon ( source, 22, 15 ) end end
  4. I have a zombie server, in this server you can collect weapons when zombies have died, you spawn with 15 colt 45 ammo if your ammo is <= 14. When you spawn you're supposed to still have all the weapons and ammo you picked up from dead zombies so you can sell it all in the shop for $1 per bullet. Players are supposed to save up their ammo to sell and make cash. I got all this coded however, in my server weapons we're saving when onPlayerWasted when they died, but if the player dies a second time without collecting any more ammo they will lose all the guns and that isnt supposed to happen. I wan't the script to save all the players weapons on death everytime and respawn with the ammo and guns they picked up while killing zombies. Basically onPlayerWasted save the weapons in each slot and when onPlayerSpawn returns the weapons the player had when he died with the correct ammo. Now i dont know if any of my scripts will effect anything but ill send you my onPlayerSpawn script i currently have for the giveWeapon when they have <= 14 colt 45 ammo outputServerLog ( "***Spawn Script Loaded ***" ) local PlayersTeam = createTeam ( "Players" ) setTeamFriendlyFire ( PlayersTeam, false ) local spawnX, spawnY, spawnZ = math.random(-694,-679), math.random(951,963), 17 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) setPlayerTeam(source, PlayersTeam ) outputChatBox("#FF00DC"..getPlayerName(source).." #ff0000Welcome To K#ff4000e#ff7f00w#ffbf00i#ffff00z#00ff00z#00ff80l#00ffffe#0080ff'#0000ffs Zombie Server, :O :O. Press \"F9\" For HELP", source, r, g, b, true) end function deathHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerWasted", getRootElement(), deathHandler) function giveWeaponsOnSpawn ( theSpawnpont, theTeam ) getammo = getPedTotalAmmo ( source, 2 ) if (getammo <= 14) then giveWeapon ( source, 22, 15 ) end end addEventHandler ( "onPlayerSpawn", getRootElement(), giveWeaponsOnSpawn ) addEventHandler ( "onPlayerLogin", getRootElement(), joinHandler ) the file for this is <script src="AZZ/spawns.lua" />
  5. thank you so much once this issue is done then i should be good. I have literally tried coding it and tried using other resources and peoples code and nothing worked at all. I literally tried everyones code and resource and coded it in a few different ways and nothing. LOL all it did is add more ammo to my pistol on spawn. If you get this to work i would be happy lol.
  6. Tried scripting this but does not work. addEventHandler ( "onPlayerWasted", getRootElement(), function() gun0 = getPedWeapon ( source, 0 ) gun1 = getPedWeapon ( source, 1 ) gun2 = getPedWeapon ( source, 2 ) gun2a = getPedTotalAmmo ( source, 2 ) gun3 = getPedWeapon ( source, 3 ) gun3a = getPedTotalAmmo ( source, 3 ) gun4 = getPedWeapon ( source, 4 ) gun4a = getPedTotalAmmo ( source, 4 ) gun5 = getPedWeapon ( source, 5 ) gun5a = getPedTotalAmmo ( source, 5 ) gun6 = getPedWeapon ( source, 6 ) gun6a = getPedTotalAmmo ( source, 6 ) gun7 = getPedWeapon ( source, 7 ) gun7a = getPedTotalAmmo ( source, 7 ) gun8 = getPedWeapon ( source, 8 ) gun8a = getPedTotalAmmo ( source, 8 ) gun9 = getPedWeapon ( source, 9 ) gun9a = getPedTotalAmmo ( source, 9 ) gun10 = getPedWeapon ( source, 10 ) gun11 = getPedWeapon ( source, 11 ) gun12 = getPedWeapon ( source, 12 ) addEventHandler ( "onPlayerSpawn", getRootElement(), function() giveWeapon( source, gun0, 1) giveWeapon( source, gun1, 1) giveWeapon( source, gun2, gun2a) giveWeapon( source, gun3, gun3a) giveWeapon( source, gun4, gun4a) giveWeapon( source, gun5, gun5a) giveWeapon( source, gun6, gun6a) giveWeapon( source, gun7, gun7a) giveWeapon( source, gun8, gun8a) giveWeapon( source, gun9, gun9a) giveWeapon( source, gun10, 1) giveWeapon( source, gun11, 1) giveWeapon( source, gun12, 1) end) end)
  7. i know that but when i die with the weapons i spawned with the first time i died then they disappear.
  8. refer to this topic. toggle control still allows you to play a tick sound.
  9. yes. one second im making a working one for you, also you had some incorrect symbols.
  10. addEventHandler("onClientPlayerWeaponFire",localPlayer,function() if (getPedTotalAmmo(localPlayer) <= 1) then cancelEvent() end end)
  11. local couch1 = createObject(2290, -663, 947.29998779297, 11.5, 0, 0, 90) function elementClicked( theButton, theState, thePlayer ) if ( theButton ) == "left" then setElementPosition(thePlayer, -662.9, 948.39611816406, 12.484375) setElementRotation(thePlayer, 0, 0, 270) setPedAnimation( thePlayer, "food", "ff_sit_look", -1, false) else setPedAnimation( thePlayer ) end end addEventHandler( "onElementClicked", couch1, elementClicked ) I know this post is old but i made this as an example for anyone who stumbles upon this post.
  12. i think i found the problem, if you dont pickup any new weapons after you die you lose the old ones when you die again. Anyone know why this could be?
  13. neither script works, if youd like join my server and test for yourself. It's in my sig. this is my spawn script aswell. outputServerLog ( "***Spawn Script Loaded ***" ) local spawnX, spawnY, spawnZ = math.random(-694,-679), math.random(951,963), 17 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("#FF00DC"..getPlayerName(source).." #ff0000Welcome To K#ff4000e#ff7f00w#ffbf00i#ffff00z#00ff00z#00ff80l#00ffffe#0080ff'#0000ffs Zombie Server, :O :O. Press \"F9\" For HELP", source, r, g, b, true) end function deathHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) addEventHandler("onPlayerWasted", getRootElement(), deathHandler) function giveWeaponsOnSpawn ( theSpawnpont, theTeam ) getammo = getPedTotalAmmo ( source, 2 ) if (getammo <= 14) then giveWeapon ( source, 22, 15 ) end end addEventHandler ( "onPlayerSpawn", getRootElement(), giveWeaponsOnSpawn ) I dont think it would bother it because even if my ammo is >= 15 it still doesnt work lol.
  14. doesnt work it works when i die once but then if i die again i lose all my weapons.
  15. sorry i keep posting here im not a noob to scripting mta resources but im also not a god.. with that said i got an error on the second death and it said [18:10:05] ERROR: zombies\save\saver.lua:17: bad argument #1 to 'pairs' (table e xpected, got nil) and i lost all my weapons. local tempData = { } addEventHandler ( "onPlayerWasted", getRootElement(), function ( ) tempData [ source ] = { weapons = getWeaponsTable ( source ), skin = getElementModel ( source ) } end ) addEventHandler ( "onPlayerSpawn", getRootElement(), function ( ) if ( tempData [ source ] ) then setElementModel ( source, tempData [ source ].skin ) for weapon, ammo in pairs ( tempData [ source ].weapons ) do giveWeapon ( source, weapon, ammo, true ) end end end ) function getWeaponsTable ( thePlayer ) local weapons = { } local hasAnyWeapon = false for slot = 0, 12 do local weapon = getPedWeapon ( thePlayer, slot ) if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( thePlayer, slot ) if ( ammo > 0 ) then weapons [ weapon ] = ammo hasAnyWeapon = true end end end if ( hasAnyWeapon ) then return weapons end end (yes i got this script from someone else.)
  16. doesnt work but are you a scriptor?
  17. okay so it almost works but when i kill more than one enemy it wont let me pick up the other pickups and it only picks up the last pickup made. outputServerLog ( "***Drop System Loaded ***" ) local state = {} local function bindState(player) bindKey(player, "f", "down", function(player) if isElement(getElementData(player,"pickup")) then usePickup(getElementData(player,"pickup"),player) removeElementData(player,"pickup") end end) end function getElementsWithinMarker(marker) if (not isElement(marker) or getElementType(marker) ~= "marker") then return false end local markerColShape = getElementColShape(marker) local elements = getElementsWithinColShape(markerColShape) return elements end addEventHandler("onResourceStart", resourceRoot, function() for _, player in pairs(getElementsByType ("player")) do bindState(player) end end) addEventHandler("onPlayerJoin", root, function() bindState(source) end) function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies if ( killer ) then if ( getElementType ( killer ) == "player" ) then x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z dropped = createPickup ( x, y, z, 2, math.random(22, 34), 15000, math.random(1,3)) dropmarker = createMarker ( x, y, z-0.5, "cylinder", 1, math.random(1, 255), math.random(1, 255), math.random(1, 255), 255) addEventHandler("onPickupHit", dropped, HitPick) addEventHandler("onMarkerHit", dropmarker, function(player) if isElement(player) and getElementType(player) == 'player' then setElementData(player,"pickup",dropped) end end) setTimer(destroyElement, 15000, 1, dropped) setTimer(destroyElement, 15000, 1, dropmarker) end end end addEventHandler("onPedWasted", getRootElement(), createDeathPickup) function HitPick ( ) if isElement ( dropped ) then cancelEvent() end end
  18. i tried to use onClientClick to pickup weapons but it doesn't seem to recognize them as an element? Does it not work with pickups?
  19. it works but one issue,my player picks the pickup up and then if i press F it picks it up a second time.
  20. i got an error server.lua:39: then expected near '='
  21. So basically i have a drop system and well i just got it to work thanks to some people here when you hold a button and then hit a pickup it picks it up. But my issue is when you hit the pickup without holding the button then press the button to pick it up nothing will happen. So i want to make it so if the player is within the marker that the pickup is in and the button is pressed it will pick the weapon up and give it to the player. heres my current code. outputServerLog ( "***Drop System Loaded ***" ) local state = {} local function bindState(player) state[player] = true bindKey(player, "f", "both", function(player) state[player] = not state[player] end) end addEventHandler("onResourceStart", resourceRoot, function() for _, player in pairs(getElementsByType ("player")) do bindState(player) end end) addEventHandler("onPlayerJoin", root, function() bindState(source) end) function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies if ( killer ) then if ( getElementType ( killer ) == "player" ) then x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z dropped = createPickup ( x, y, z, 2, math.random(22, 34), 15000, math.random(1,3)) dropmarker = createMarker ( x, y, z-0.5, "cylinder", 1, math.random(1, 255), math.random(1, 255), math.random(1, 255), 255) addEventHandler("onPickupHit", dropped, function(player) cancelEvent(state[player]) end) setTimer(destroyElement, 15000, 1, dropped) setTimer(destroyElement, 15000, 1, dropmarker) end end end addEventHandler("onPedWasted", getRootElement(), createDeathPickup)
  22. if its not possible maybe thinking of creating a marker thats invisible on a dropped item and then destroying it on pickup and it would be like if(isElementWithinMarker(marker) == true then somefunction binded L to use the pickup.
×
×
  • Create New...