illestiraqi Posted October 17, 2012 Share Posted October 17, 2012 So In this script, it's been found, and the bind is to press "l" to drop a weapon but i want it changed to... like in game when they open that chat thing when they press T the say thing comes out i want the command to be /dropwep please! throwWeaponPickup = {} function throwWeapon(thePlayer, key, keyState) if (not isPedInVehicle(thePlayer)) then local theIDweapon = getPedWeapon(thePlayer) local theTotalAmmo = getPedTotalAmmo(thePlayer) if theIDweapon then local x,y,z = getElementPosition(thePlayer) local rot = getPedRotation(thePlayer) x = x + ((math.cos(math.rad(rot + 90))) * 2.5) y = y + ((math.sin(math.rad(rot + 90))) * 2.5) for i,players in ipairs(getElementsByType("player")) do local px,py,pz = getElementPosition(players) if getDistanceBetweenPoints2D(x, y, px,py) < 2 then --//If the distance from the player's point of pickup truck dumping jetty is given weapons to this player. if (getPedWeapon(players, getSlotFromWeapon(theIDweapon)) == 0) then --//Check whether the player has a slot for this weapon, it is not blocked. takeWeapon(thePlayer, theIDweapon) giveWeapon(players, theIDweapon, theTotalAmmo) outputChatBox(getPlayerName(thePlayer).." gave you [Weapons]: "..getWeaponNameFromID(theIDweapon)..", [Patrons]: "..tostring(theTotalAmmo), players, 184, 138, 0) outputChatBox("you have transferred [Weapons]: "..getWeaponNameFromID(theIDweapon)..", [Patrons]: "..tostring(theTotalAmmo)..", "..getPlayerName(players), thePlayer, 184, 138, 0) return 0 else outputChatBox(getPlayerName(players).." already has weapons of this type! ", thePlayer, 184, 138, 0) return 0 end end end takeWeapon(thePlayer, theIDweapon) throwWeaponPickup[#throwWeaponPickup+1] = createPickup(x, y, z, 2, theIDweapon, 10000, theTotalAmmo) end end end --//Bind keys to work with weapons. function bindTheKeys() if (not isKeyBound(source, "l")) then bindKey(source, "l", "down", throwWeapon) end end addEventHandler("onPlayerSpawn", getRootElement(), bindTheKeys) Link to comment
Castillo Posted October 17, 2012 Share Posted October 17, 2012 You want to replace the bind with a command? if so: throwWeaponPickup = {} function throwWeapon(thePlayer) if (not isPedInVehicle(thePlayer)) then local theIDweapon = getPedWeapon(thePlayer) local theTotalAmmo = getPedTotalAmmo(thePlayer) if theIDweapon then local x,y,z = getElementPosition(thePlayer) local rot = getPedRotation(thePlayer) x = x + ((math.cos(math.rad(rot + 90))) * 2.5) y = y + ((math.sin(math.rad(rot + 90))) * 2.5) for i,players in ipairs(getElementsByType("player")) do local px,py,pz = getElementPosition(players) if getDistanceBetweenPoints2D(x, y, px,py) < 2 then --//If the distance from the player's point of pickup truck dumping jetty is given weapons to this player. if (getPedWeapon(players, getSlotFromWeapon(theIDweapon)) == 0) then --//Check whether the player has a slot for this weapon, it is not blocked. takeWeapon(thePlayer, theIDweapon) giveWeapon(players, theIDweapon, theTotalAmmo) outputChatBox(getPlayerName(thePlayer).." gave you [Weapons]: "..getWeaponNameFromID(theIDweapon)..", [Patrons]: "..tostring(theTotalAmmo), players, 184, 138, 0) outputChatBox("you have transferred [Weapons]: "..getWeaponNameFromID(theIDweapon)..", [Patrons]: "..tostring(theTotalAmmo)..", "..getPlayerName(players), thePlayer, 184, 138, 0) return 0 else outputChatBox(getPlayerName(players).." already has weapons of this type! ", thePlayer, 184, 138, 0) return 0 end end end takeWeapon(thePlayer, theIDweapon) throwWeaponPickup[#throwWeaponPickup+1] = createPickup(x, y, z, 2, theIDweapon, 10000, theTotalAmmo) end end end addCommandHandler ( "dropwep", throwWeapon ) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now