KryngeerPL Posted November 11, 2014 Share Posted November 11, 2014 (edited) Hello guys. I need a script which will be forbid weapons. I found this script https://community.multitheftauto.com/index.php?p=resources&s=details&id=3531 but it's blocking getting weapons for every group. I try to change it, but i'm noob in LUA and it doesn't work. Can anyone make a script for this? Edited November 11, 2014 by Guest Link to comment
Moderators IIYAMA Posted November 11, 2014 Moderators Share Posted November 11, 2014 This section is NOT for requesting. Give that a try on the resource section. Link to comment
KryngeerPL Posted November 11, 2014 Author Share Posted November 11, 2014 Can moderator move my topic to right section? Link to comment
Bilal135 Posted November 11, 2014 Share Posted November 11, 2014 function lolTeam(Player) local theTeam = getPlayerTeam(Player) if theTeam == "Team Name" then toggleControl("mouse1", true) else toggleControl("mouse1", false) end end addEventHandler("onPlayerWeaponSwitch", root, lolTeam) Didn't have time to test it, hope it works. Link to comment
Anubhav Posted November 11, 2014 Share Posted November 11, 2014 (edited) Never would. function lolTeam(_, weaponid) local theTeam = getTeamName(getPlayerTeam(source)) if theTeam and theTeam == "Team Name" and weaponid == yourWeaponId then toggleControl( source, "fire", true ) else toggleControl( source, "fire", false ) end end addEventHandler("onPlayerWeaponSwitch", root, lolTeam) Edited November 11, 2014 by Guest Link to comment
KryngeerPL Posted November 11, 2014 Author Share Posted November 11, 2014 And can I get a script for despawning vehicles? because mtasa.com server has some problems with pages, so I can't go to wiki for destroyObject. Link to comment
KryngeerPL Posted November 11, 2014 Author Share Posted November 11, 2014 Never would. function lolTeam(_, weaponid) local theTeam = getTeamName(getPlayerTeam(source)) if theTeam == "Team Name" and weaponid == yourWeaponId then toggleControl("fire", true) else toggleControl("fire", false) end end addEventHandler("onPlayerWeaponSwitch", root, lolTeam) It doesn't work. First I add it for server side, but it cause this: [2014-11-11 15:02:23] WARNING: forbidweapons\server.lua:2: Bad argument @ 'getTeamName' [Expected team at argument 1, got boolean] [2014-11-11 15:02:23] WARNING: forbidweapons\server.lua:6: Bad argument @ 'toggleControl' [Expected player at argument 1, got string 'fire'] Link to comment
Anubhav Posted November 11, 2014 Share Posted November 11, 2014 edit: see my edited code There is no such thing as destroyObject. It's destroyElement. Here you go . his function destroys an element and all elements within it in the hierarchy (its children, the children of those children etc). Player elements cannot be destroyed using this function. A player can only be removed from the hierarchy when they quit or are kicked. The root element also cannot be destroyed, however, passing the root as an argument will wipe all elements from the server, except for the players and clients, which will become direct descendants of the root node, and other elements that cannot be destroyed, such as resource root elements. Players are not the only elements that cannot be deleted. This list also includes remote clients and console elements. Note: As element ids are eventually recycled, always make sure you nil variables containing the element after calling this function Syntax bool destroyElement ( element elementToDestroy ) OOP Syntax Note: This function is also a static function underneath the Element class. Method: element:destroy() Required Arguments elementToDestroy: The element you wish to destroy. Returns Returns true if the element was destroyed successfully, false if either the element passed to it was invalid or it could not be destroyed for some other reason (for example, clientside destroyElement can't destroy serverside elements). Example Example 1: This example would destroy every element in the map, with the exception of players and the root element itself. -- Find the root element (the element that contains all others) root = getRootElement () -- Destroy all its children, except players. destroyElement ( root ) Example 2: This example destroys all vehicles of the specified model: function destroyVehiclesOfModel(modelID) -- get a table of all the vehicles that exist and loop through it local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- if the vehicle's ID is the one provided, destroy it if (getElementModel(v) == modelID) then destroyElement(v) end end end destroyVehiclesOfModel(445) Example 3: This example allows creation of claymores, which trigger and explode. When they explode, the colshape and object for the claymore are destroyed. function createClaymore ( x,y,z, creator ) local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 ) -- create an object which looks like a claymore local claymoreCol = createColSphere ( x, y, z, 1 ) -- create a col sphere with radius 1 setElementData ( claymoreCol, "object", claymoreObject ) -- store the object of the claymore setElementData ( claymoreCol, "creatorPlayer", creator ) -- store the person who created it addEventHandler ( "onColShapeHit", claymoreCol, claymoreHit ) -- add an event handler to the colshape end function claymoreHit ( thePlayer, matchingDimension ) -- retrieve the object associated to the claymore, and who created it local claymoreObject = getElementData ( source, "object" ) local claymoreCreator = getElementData ( source, "creatorPlayer" ) -- get the position of the claymore local x,y,z = getElementPosition ( source ) createExplosion ( x,y,z, 12, claymoreCreator ) -- create an explosion, associated to the creator, of a small size at the col's position -- remove the event handler for the colshape removeEventHandler ( "onColShapeHit", source, claymoreHit ) -- destroy the claymore object, and the col shape so it doesn't trigger again. destroyElement ( claymoreObject ) destroyElement ( source ) end Example 4: This example destroys all vehicles, regardless of ID, name, etc: function allvehiclesaredoomed() -- get a table of all the vehicles that exist and loop through it vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- destroy every vehicle. destroyElement(v) end end --The command handler below will destroy all vehicles once --you enter /vdoom in the chat box or vdoom in the game console. addCommandHandler("vdoom", allvehiclesaredoomed) --This is very useful if you use the freeroam resource and some --heartless players start spawn spamming. --You can also set it on a timer to have your server clear all --vehicles ever 60 minutes, (1 hour). Timer below: setTimer(allvehiclesaredoomed, 3600000, 0) Your wiki is here! note: I just copy pasted.! Link to comment
KryngeerPL Posted November 11, 2014 Author Share Posted November 11, 2014 There is no such thing as destroyObject. It's destroyElement.Here you go . his function destroys an element and all elements within it in the hierarchy (its children, the children of those children etc). Player elements cannot be destroyed using this function. A player can only be removed from the hierarchy when they quit or are kicked. The root element also cannot be destroyed, however, passing the root as an argument will wipe all elements from the server, except for the players and clients, which will become direct descendants of the root node, and other elements that cannot be destroyed, such as resource root elements. Players are not the only elements that cannot be deleted. This list also includes remote clients and console elements. Note: As element ids are eventually recycled, always make sure you nil variables containing the element after calling this function Syntax bool destroyElement ( element elementToDestroy ) OOP Syntax Note: This function is also a static function underneath the Element class. Method: element:destroy() Required Arguments elementToDestroy: The element you wish to destroy. Returns Returns true if the element was destroyed successfully, false if either the element passed to it was invalid or it could not be destroyed for some other reason (for example, clientside destroyElement can't destroy serverside elements). Example Example 1: This example would destroy every element in the map, with the exception of players and the root element itself. -- Find the root element (the element that contains all others) root = getRootElement () -- Destroy all its children, except players. destroyElement ( root ) Example 2: This example destroys all vehicles of the specified model: function destroyVehiclesOfModel(modelID) -- get a table of all the vehicles that exist and loop through it local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- if the vehicle's ID is the one provided, destroy it if (getElementModel(v) == modelID) then destroyElement(v) end end end destroyVehiclesOfModel(445) Example 3: This example allows creation of claymores, which trigger and explode. When they explode, the colshape and object for the claymore are destroyed. function createClaymore ( x,y,z, creator ) local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 ) -- create an object which looks like a claymore local claymoreCol = createColSphere ( x, y, z, 1 ) -- create a col sphere with radius 1 setElementData ( claymoreCol, "object", claymoreObject ) -- store the object of the claymore setElementData ( claymoreCol, "creatorPlayer", creator ) -- store the person who created it addEventHandler ( "onColShapeHit", claymoreCol, claymoreHit ) -- add an event handler to the colshape end function claymoreHit ( thePlayer, matchingDimension ) -- retrieve the object associated to the claymore, and who created it local claymoreObject = getElementData ( source, "object" ) local claymoreCreator = getElementData ( source, "creatorPlayer" ) -- get the position of the claymore local x,y,z = getElementPosition ( source ) createExplosion ( x,y,z, 12, claymoreCreator ) -- create an explosion, associated to the creator, of a small size at the col's position -- remove the event handler for the colshape removeEventHandler ( "onColShapeHit", source, claymoreHit ) -- destroy the claymore object, and the col shape so it doesn't trigger again. destroyElement ( claymoreObject ) destroyElement ( source ) end Example 4: This example destroys all vehicles, regardless of ID, name, etc: function allvehiclesaredoomed() -- get a table of all the vehicles that exist and loop through it vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- destroy every vehicle. destroyElement(v) end end --The command handler below will destroy all vehicles once --you enter /vdoom in the chat box or vdoom in the game console. addCommandHandler("vdoom", allvehiclesaredoomed) --This is very useful if you use the freeroam resource and some --heartless players start spawn spamming. --You can also set it on a timer to have your server clear all --vehicles ever 60 minutes, (1 hour). Timer below: setTimer(allvehiclesaredoomed, 3600000, 0) Your wiki is here! note: I just copy pasted.! And who can add a line with isObjectInACLGroup? Please, I'm noob in LUA and if I will do it, it won't work.... Link to comment
Anubhav Posted November 11, 2014 Share Posted November 11, 2014 Which example are you talking about Link to comment
KryngeerPL Posted November 11, 2014 Author Share Posted November 11, 2014 function destroyVehiclesOfModel(modelID) -- get a table of all the vehicles that exist and loop through it local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- if the vehicle's ID is the one provided, destroy it if (getElementModel(v) == modelID) then destroyElement(v) end end end Link to comment
Moderators IIYAMA Posted November 11, 2014 Moderators Share Posted November 11, 2014 Seriously Bilal135, writting code for a requester? If you are too stuppid to support the rule breakers, use atleast the pm system. From those requests we only get more requests and this section loses it's purpose. You are also destroying it for yourself. Link to comment
Anubhav Posted November 11, 2014 Share Posted November 11, 2014 function destroyVehiclesOfModel(modelID) -- get a table of all the vehicles that exist and loop through it local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- if the vehicle's ID is the one provided, destroy it if (getElementModel(v) == modelID) then destroyElement(v) end end end Why would you add isObjectInACLGroup in it? Link to comment
KryngeerPL Posted November 12, 2014 Author Share Posted November 12, 2014 Sorry I mistake this topic with my other one. I want here isVehicleEmpty because my console say it's bad argument etc. Link to comment
Bilal135 Posted November 12, 2014 Share Posted November 12, 2014 Sorry I mistake this topic with my other one. I want here isVehicleEmpty because my console say it's bad argument etc. Show your code. Link to comment
KryngeerPL Posted November 13, 2014 Author Share Posted November 13, 2014 function destroyVehiclesOfModel(modelID) -- get a table of all the vehicles that exist and loop through it local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- if the vehicle's ID is the one provided, destroy it if (getElementModel(v) == modelID) then destroyElement(v) end end end I want to change it for all vehicles, not for 1 type and i want to destroy vehicles if they're empty. I'm not want any timer, I want only command. 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