Jump to content

knightscript

Members
  • Posts

    127
  • Joined

  • Last visited

Everything posted by knightscript

  1. hey tosfera, if for example, i have shoot a player with 100% health and 10% armor, and my weapon does 20% per shot, how can set it to delete the players armor and if there is any number of damage left, remove it from the health?
  2. Alright, thanks, one more thing, when i set all weapons properties damage to 0, also the accuracy goes to maximum, do you know how can i fix this?
  3. Hello, im trying to create a new damage system, first by Setting all weapon´s properties damage to 0, and afterwards, and then getelementdata of the player, if he is in group "Everyone" then get the damage in the element, etc, but what I want to do is this: 1.) check if the player has armor, 2.) if he has armor, check how much is it, 3.) if the damage specified in getelementdata of the attacker is for example, 20, and the player has 10% armor, i want to be able to remove 10% armor and 10% health. I don´t know if im explaining myself. I hope yes, what functions should i use? thanks.
  4. Hello Mega9, i just added you on Skype
  5. Sometimes some vehicle mods lag crazily, I have a friend who normaly has 80fps, and when he gets close to one of my modded vehicles he goes all the way down to 15!, so yeah, try disabling car mods, could work, also, what are your PC Specs? it can also be just a bad PC.
  6. Hey!, well, I´m an administrator of a great MTA server, its called Invasion Z (thezombiworld.com), you can test it out if you want to, there is people who speaks english there, not all of them, but yeah, you should give it a try TeamSpeak 3: thezombiworld.com:7777 MTA Server: 192.99.59.146:22003
  7. Sorry, didn´t know! I considered this just a little script.
  8. Hello Everyone!, this is a quick tutorial on how to restart a resource by using PHP. You will need the following things: -Web hosting with PHP support. -FTP access to your MTA server. First, lets start with the LUA code, so, if you want to implement this code, ignore the meta.xml file, and just add the code from myscript.lua. So lets start the the LUA coding, first, we want to create a folder, for now, lets name it "restartmyresource", and make 2 files inside, meta.xml and myscript.lua. I will comment out everything as best as i can, here we go meta.xml: <meta> <script src="server.lua" type="server" /> <!--defines that our script is named myscript.lua and that it is server-sided, it is not necesary--> <export function="RestartResource" type="server" http="true" /> <!--this allows us to use PHP SDK to execute a function--> <aclrequest> <right name="function.aclGroupAddObject" access="true"></right> <!--makes the request to access ACL group´s--> <right name="function.restartResource" access="true"></right> <!--makes the resource to restart--> </aclrequest> </meta> resourceRoot = getResourceRootElement() function RestartResource () --function that executes the restart of the resource local resource = getResourceFromName("VIP-Cars") --gets the resource that has the name VIP-Cars outputDebugString("checking if VIP-Cars is running.") --outputs a message on the debugscript saying that it is checking if the resource is running. if (resource and getResourceState(resource) == "running") then --if resource is running... outputDebugString("restarting resource VIP-Cars.") --outputs message on the debugscript.. outputChatBox("Resources are being restarted") --outputs message on the chatbox.. restartResource(resource) --restarts the resource.. else --if the resource is not running end --end if (resource and getResourceState(resource) == "loaded") then --if resource is loaded outputDebugString("starting resource VIP-Cars.") --output message on the debugscript.. outputChatBox("Resources are being started") --outputs message on the chatbox.. startResource(resource) --starts the resource.. end end addCommandHandler("restartres",RestartResource) --testing command function createadminacc(res) --function that creates the account and give it the needed rights if getAccount("phpsdkacc") then --if the account already exists outputDebugString("The PHP SDK account already exists.") --output it to debugscript if isObjectInACLGroup ("user.phpsdkacc", aclGetGroup ( "Admin" ) ) then --if the account has the needed rights outputDebugString("The PHP SDK account already has Admin rights.") --output it to debugscript else --if not outputDebugString("The PHP SDK account does not have the needed rights, adding them.") --the account doesnt have the needed rights if aclGroupAddObject (aclGetGroup("Admin"), "user.phpsdkacc") == true then --if the script was able to add the account rights outputDebugString ("Assigned the PHP SDK account the needed rights successfully.") --output message on the debugscript else --if the script wasnt able to add the account rights outputDebugString ("Couldnt assign the rights needed to the PHP SDK account, the resource doesnt have the needed rights, add them by typing on your console: aclrequest allow ".. getResourceName(res) .." all.") --output on debugscript end end else --if the account doesnt exist addAccount("phpsdkacc", "testingpassword" ) --add the account outputDebugString("The PHP SDK account has been created since it didn´t exist.") --outputs on debugscript if aclGroupAddObject (aclGetGroup("Admin"), "user.phpsdkacc") == true then --if the script was able to add the account rights outputDebugString ("Assigned the PHP SDK account the needed rights successfully.") --output it on debugscript else --if not outputDebugString ("Couldnt assign the rights needed to the PHP SDK account, the resource doesnt have the needed rights, add them by typing on your console: aclrequest allow ".. getResourceName(res) .." all.") --output on debugscript end end end addEventHandler("onResourceStart",resourceRoot,createadminacc) --execute this each time the resource starts you are going to need to add this resource to your ACL as admin, or you can use the command on the console "aclrequest allow resourcename all". So, here you can edit 2 things, all phpsdkacc fields and testingpassword, here is an example of what would show up if the account already existed and had rights: example of what would show up if the account didnt exist, created it and added rights: example of what would show up if the account was added, but couldnt add the rights because of permitions: Now you want to add your resource to startup with the server, so first, open up your mtaserver.conf and add this at the ending: <resource src="restartresources" startup="1" protected="0" /><!--WHERE restartresources would be your script folder name--> and that would be it for LUA!, lets jump onto my speciality, PHP!. First, we need to get the MTA PHP SDK, we can get it from here! (version 0.4) Second, we need to extract its contents on our public_html folder, and should look like this: So now, we create a file called index.php, and we paste the following: <meta charset="utf8"> <!--Set our character set to utf8, if it is needed--> <?php include( "mta_sdk.php" ); //includes the MTA SDK $mtaServer = new mta("123.123.123.123", 22005, "phpsdkacc", "testingpassword"); //we create the connection to our server, where first argument would be IP, second argument would be HTTP Port, third argument would be username and forth argument would be password $mtaServer->getResource("restartresources")->call("RestartResource"); //calls the function ?> Now if we want to add a little bit of security, then we can use the following: replace everything under : <?php $password = $_POST['passwd']; //stores the password into a variable $mypassword = "knightsv"; //your password if ($_SERVER['REQUEST_METHOD'] == 'POST') { //checks if the post has been sent if ($password == $mypassword) { //checks if the password that was entered was the same as the defined password echo "<h1>Correct Password! the resource has been restarted, if the correct data has been inserted.</h1>"; //just a simple message include( "mta_sdk.php" ); //includes the mta sdk $mtaServer = new mta("123.123.123.123", 22005, "phpsdkacc", "testingpassword"); //creates the connection to the mta server where first argument is the server ip, second argument is the server HTTP port, third argument is the user account, and fourth argument would be the password of the account. $resource = $mtaServer->getResource ("restartresources"); //calls the resource $returns[] = $resource->call("RestartResource"); //calls the function }else{ //if the password was incorrect echo "Wrong password"; //display message } }else { //if the post wasn´t made ?> <form method="post"> <input type="password" name="passwd"> <input type="submit"> </form> <?php }?> If you´d want you could create multiple functions to restart multiple resources, or restart multiple resources on 1 function: This script is not very good at restarting more than 1 resource on the same function, if you need it, then you can go to this link: https://forum.multitheftauto.com/viewto ... 91&t=37809 There you can find a script which would allow you to get the resources from a file. BUT if you want to do so, then you can just duplicate this lines: local resource = getResourceFromName("VIP-Cars") --gets the resource that has the name VIP-Cars outputDebugString("checking if VIP-Cars is running.") --outputs a message on the debugscript saying that it is checking if the resource is running. if (resource and getResourceState(resource) == "running") then --if resource is running... outputDebugString("restarting resource VIP-Cars.") --outputs message on the debugscript.. outputChatBox("Resources are being restarted") --outputs message on the chatbox.. restartResource(resource) --restarts the resource.. else --if the resource is not running end --end if (resource and getResourceState(resource) == "loaded") then --if resource is loaded outputDebugString("starting resource VIP-Cars.") --output message on the debugscript.. outputChatBox("Resources are being started") --outputs message on the chatbox.. startResource(resource) --starts the resource.. end and just change local resource to for example local resource2, for example: function RestartResource () --function that executes the restart of the resource local resource = getResourceFromName("VIP-Cars") --gets the resource that has the name VIP-Cars outputDebugString("checking if VIP-Cars is running.") --outputs a message on the debugscript saying that it is checking if the resource is running. if (resource and getResourceState(resource) == "running") then --if resource is running... outputDebugString("restarting resource VIP-Cars.") --outputs message on the debugscript.. outputChatBox("Resources are being restarted") --outputs message on the chatbox.. restartResource(resource) --restarts the resource.. else --if the resource is not running end --end if (resource and getResourceState(resource) == "loaded") then --if resource is loaded outputDebugString("starting resource VIP-Cars.") --output message on the debugscript.. outputChatBox("Resources are being started") --outputs message on the chatbox.. startResource(resource) --starts the resource.. end ----------------------------------------------------------------------------------------- local resource2 = getResourceFromName("VIP-Skins") --gets the resource2 that has the name VIP-Skins outputDebugString("checking if VIP-Skins is running.") --outputs a message on the debugscript saying that it is checking if the resource2 is running. if (resource2 and getResourceState(resource2) == "running") then --if resource2 is running... outputDebugString("restarting resource2 VIP-Skins.") --outputs message on the debugscript.. outputChatBox("Resources are being restarted") --outputs message on the chatbox.. restartResource(resource2) --restarts the resource2.. else --if the resource is not running end --end if (resource and getResourceState(resource) == "loaded") then --if resource is loaded outputDebugString("starting resource VIP-Skins.") --output message on the debugscript.. outputChatBox("Resources are being started") --outputs message on the chatbox.. startResource(resource2) --starts the resource.. end end This script would restart both resources, VIP-Skins and VIP-Cars on the call of the function. Now, if you want to have multiple functions for multiple resources, you can just rename the function name, and of course, the resource name, example: function RestartResource () --function that executes the restart of the resource local resource = getResourceFromName("VIP-Cars") --gets the resource that has the name VIP-Cars outputDebugString("checking if VIP-Cars is running.") --outputs a message on the debugscript saying that it is checking if the resource is running. if (resource and getResourceState(resource) == "running") then --if resource is running... outputDebugString("restarting resource VIP-Cars.") --outputs message on the debugscript.. outputChatBox("Resources are being restarted") --outputs message on the chatbox.. restartResource(resource) --restarts the resource.. else --if the resource is not running end --end if (resource and getResourceState(resource) == "loaded") then --if resource is loaded outputDebugString("starting resource VIP-Cars.") --output message on the debugscript.. outputChatBox("Resources are being started") --outputs message on the chatbox.. startResource(resource) --starts the resource.. end end function RestartResource2 () --function that executes the restart of the resource local resource = getResourceFromName("VIP-Skins") --gets the resource that has the name VIP-Cars outputDebugString("checking if VIP-Cars is running.") --outputs a message on the debugscript saying that it is checking if the resource is running. if (resource and getResourceState(resource) == "running") then --if resource is running... outputDebugString("restarting resource VIP-Cars.") --outputs message on the debugscript.. outputChatBox("Resources are being restarted") --outputs message on the chatbox.. restartResource(resource) --restarts the resource.. else --if the resource is not running end --end if (resource and getResourceState(resource) == "loaded") then --if resource is loaded outputDebugString("starting resource VIP-Cars.") --output message on the debugscript.. outputChatBox("Resources are being started") --outputs message on the chatbox.. startResource(resource) --starts the resource.. end end DON´T FORGET to add your export on the meta, like this: <export function="RestartResource2" type="server" http="true" /> <!--this allows us to use PHP SDK to execute a function--> and for the PHP, you have many options, the easiest option would be making a dropdown, so lets get to it: <meta charset="utf8"> <!--Set our character set to password--> <?php $password = $_POST['passwd']; $mypassword = "knightsv"; $whichresource = $_POST['whichresource']; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($password == $mypassword) { echo "<h1>Correct Password!.</h1>"; include( "mta_sdk.php" ); $mtaServer = new mta("123.123.123.123", 22005, "phpsdkacc", "testingpassword"); $resource = $mtaServer->getResource ("restartresources"); if ($whichresource == "VIP-Cars"){ $returns[] = $resource->call("RestartResource"); } if ($whichresource == "VIP-Skins") { $returns[] = $resource->call("RestartResource2"); } }else{ echo "Wrong password"; } }else{?> <form method="post"> <label>Your Password: </label><input type="password" name="passwd"> <label>Resource Name:</label> <select name="whichresource"> <option value="VIP-Cars">VIP Cars</option> <option value="VIP-Skins">VIP Skins</option> </select> <input type="submit"> </form> <?php }?> Once this is made, i can see the PHP site like this: And, if i click the dropdown, it displays this: If i input the correct password, and select VIP Cars, then when i press the send button, this happens on the server: If i input the correct password, and select VIP Skins, then when i press the send button, this happens on the server: That would be it for today, havent slept in 2 days, I hope you liked my post, if so feel free to leave a reply and I will try to answer any questions I can! Good luck!.
  9. Thanks @toni012899, i have updated this post and added a second option on how to add an ACL
  10. Added OnPlayerQuit and also added new method to change account.
  11. Well i don´t know if that is possible, but you can warp the ped directly inside a vehicle with this: function warpped( ) local Ped = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) local Vehicle = createVehicle ( 411, 4, 0, 3 ) warpPedIntoVehicle ( Ped, Vehicle ) --you can set the seat where the player would be warped to, example: --warpPedIntoVehicle ( Ped, Vehicle, 0) --Warps the vehicle as the driver end addCommandHandler ( "warp1", warpped) --command EDIT: If you want to warp the ped to your current vehicle, replace local Vehicle = createVehicle ( 411, 4, 0, 3 ) with local Vehicle = getPedOccupiedVehicle (source) I Didn´t test this, if you need more help just reply and I will try my best EDIT: tested:
  12. What do you want to do?, you want to get who opened the vehicle door?
  13. Its just a simple code for noobies like me, had a hard time making this and I´m sure there is more people out there trying, hope this helps
  14. Can you explain better what you want to achieve?.
  15. Hello, I´m sharing the script I´m using on my server (see signature) to spawn a vehicle, which would be ONLY accessible to the account you choose, so here we go, First, if you are going to make this a resource and not included to the gamemode, then you want to create a folder, lets name our folder mycustomcar, afterwards, we want to create 2 files: * meta.xml * car.lua so your folder should look like this: Afterwards, we open our meta.xml file and paste the following: <meta> <info author="YourNickname" type="script" name="My Custom car by user account" /> <!--This doesn´t really have to be on your script.--> <script src="car.lua" type="server" /> <!--Defines where your script is, and that it is server-sided.--> </meta> So now, we are going to open our file named car.xml, and we insert the following code: allowedaccount = "admin" --The account that is allowed to spawn the car function mycarbyuseracc(player) --create the function local account = getAccountName(getPlayerAccount(player)) --get the player account if account == allowedaccount then --if current player account matches allowed accounts, then do: if (isElement(getElementData(player, "knightcar1"))) then --check if there is another vehicle that was spawned by the same command destroyElement(getElementData(player, "knightcar1")) --destroy it end --finalize what happens if there is another vehicle outputChatBox("Welcome, "..account.."!.", player, 0, 255, 0, false) --displays to the player a text, you can remove this if you don´t want to show anything outputChatBox("Here is your car! Have fun!", player, 0, 255, 0, false) --displays one more text to the player local x,y,z = getElementPosition(player) --gets the X, Y and Z of the player and stores it in a variable local rotX, rotY, rotZ = getElementRotation(player) -- gets the rotation of the player and stores it in a variable local veh = createVehicle("602",x,y +-2,z +2) --creates the vehicle with id 602 (alpha), what you see at the end of z, makes the vehicle spawn a little bit over the ground, it can sometimes bug on the floor if not, see complete vehicle ID´s at [url=https://wiki.multitheftauto.com/wiki/Vehicle_IDs]https://wiki.multitheftauto.com/wiki/Vehicle_IDs[/url] setElementRotation(veh,rotX,rotY,rotZ+10) --sets the vehicle rotation as the player rotation setVehicleHeadLightColor (veh,255,0,0) --sets the vehicle lights color to red, (RGB) setVehicleColor (veh,255,0,0) --sets the vehicle color to red, (RGB) --YOU CAN GENERATE COLORS ON THIS WEBSITE, [url=http://www.rapidtables.com/web/color/RGB_Color.htm]http://www.rapidtables.com/web/color/RGB_Color.htm[/url] setElementData(player, "knightcar1", veh) --set the vehicles element to mycarmustang, if you changed the above element datas, then you must change thisone too, -- warpPedIntoVehicle(player,veh) --this is if you want to warp the player inside the vehicle one it spawns end end addEventHandler( "onPlayerQuit", getRootElement( ),function() --when player quits... if (isElement(getElementData(source, "knightcar1"))) then --if vehicle exists destroyElement(getElementData(source, "knightcar1")) --destroy vehicle --outputDebugString ( "1 car by Knight Destroyed." ) --just for debuging purposes end end) and you also must add the Command, lets say i want to spawn the car with the command /MyCarRed: addCommandHandler("MyCarRed",mycarbyuseracc) Just for you to remember, commands are CASE SENSITIVE!. So, when you type /MyCarRed, this would show up: When you type /MyCarRed for the second time, your old vehicle will disappear, if you dont want this to happen, just delete or comment out this lines (add "--" at the beggining of the line): if (isElement(getElementData(player, "mycarmustang"))) then destroyElement(getElementData(player, "mycarmustang")) end If you want to make your vehicle everything damageproof, add this: setVehicleDamageProof(veh, true) --where true means yes, if you change true to false, it will disable this. EDIT: with this modifications, instead of having to edit the LUA script, you can edit it directly from your server So lets start, first, open your meta.xml file, and paste the following: <meta> <info author="YourNickname" type="script" name="My Custom car by user account" /> <!--This doesn´t really have to be on your script.--> <script src="car.lua" type="server" /> <!--Defines where your script is, and that it is server-sided.--> <settings> <setting name="*Account" value="admin" /> <!--Here you must define the account that can spawn the car --> </settings> </meta> Afterwards, you are going to want to edit your car.lua file, and REPLACE with the following code: function mycarbyuseracc(player) --create the function local account = getAccountName(getPlayerAccount(player)) --get the player account if account == get("Account") then --if current player account matches allowed account, then do: if (isElement(getElementData(player, "mycar1"))) then --check if there is another vehicle that was spawned by the same command destroyElement(getElementData(player, "mycar1")) --destroy it end --finalize what happens if there is another vehicle outputChatBox("Welcome, "..account.."!.", player, 0, 255, 0, false) --displays to the player a text, you can remove this if you don´t want to show anything outputChatBox("Here is your car! Have fun!", player, 0, 255, 0, false) --displays one more text to the player local x,y,z = getElementPosition(player) --gets the X, Y and Z of the player and stores it in a variable local rotX, rotY, rotZ = getElementRotation(player) -- gets the rotation of the player and stores it in a variable local veh = createVehicle("602",x,y +-2,z +2) --creates the vehicle with id 602 (alpha), what you see at the end of z, makes the vehicle spawn a little bit over the ground, it can sometimes bug on the floor if not, see complete vehicle ID´s at [url=https://wiki.multitheftauto.com/wiki/Vehicle_IDs]https://wiki.multitheftauto.com/wiki/Vehicle_IDs[/url] setElementRotation(veh,rotX,rotY,rotZ+10) --sets the vehicle rotation as the player rotation setVehicleHeadLightColor (veh,255,0,0) --sets the vehicle lights color to red, (RGB) setVehicleColor (veh,255,0,0) --sets the vehicle color to red, (RGB) --YOU CAN GENERATE COLORS ON THIS WEBSITE, [url=http://www.rapidtables.com/web/color/RGB_Color.htm]http://www.rapidtables.com/web/color/RGB_Color.htm[/url] setElementData(player, "mycar1", veh) --set the vehicles element to mycarmustang, if you changed the above element datas, then you must change thisone too, -- warpPedIntoVehicle(player,veh) --this is if you want to warp the player inside the vehicle one it spawns end end And the command: addCommandHandler("mycar",mycarbyuseracc) --command would be /mycar So, you can edit the account that can use the vehicle by 2 methods: 1.) By editing the XML: You can edit the XML and edit value="admin" to the account name you want to use, for example: <!--<setting name="*Account" value="admin" />--> <!--OLD ACCOUNT--> <setting name="*Account" value="myaccount" /> <!--MY NEW ACCOUNT--> 2.) By editing the option on your admin panel: For this, you will need to have the resource ADMIN started on your server, afterwards, press letter P to start your admin panel, you will see something like this: You will want to go to the tab named Resources, and you will see a searchbox, in which you will type in the name of the folder you created, remember to move your folder to the server´s resources folder, once you search for your folder´s name, you will see something like this: By double clicking it, you will see something like this: Once you are here, you want to double click the field "Account", and you will see a textbox like thisone: Just replace the content with the account name you want, and click OK, then restart the resource by clicking "Restart", you can see it located here: If your resource shows up like "loaded", click on Start, if your resource shows up like "running", click on Restart. So that would be it! Thanks for visiting my post!
  16. Hello, I´m sharing the script I´m using on my server (see signature) to spawn a vehicle, which would be ONLY accessible to the ACL group you choose, so here we go, First, if you are going to make this a resource and not included to the gamemode, then you want to create a folder, lets name our folder mycustomcar, afterwards, we want to create 2 files: * meta.xml * car.lua so your folder should look like this: Afterwards, we open our meta.xml file and paste the following: <meta> <info author="YourNickname" type="script" name="My Custom car by ACL" /> <!--This doesn´t really have to be on your script.--> <script src="car.lua" type="server" /> <!--Defines where your script is, and that it is server-sided.--> </meta> So now, we are going to open our file named car.xml, and we paste the following: function mycar(player) local account = getAccountName(getPlayerAccount(player)) --get the player account if isObjectInACLGroup("user." .. account, aclGetGroup("Owners")) then --check if player who typed the command is in ACL "Owners" if (isElement(getElementData(player, "mycarmustang"))) then --checks if the car element already existed, if so destroyElement(getElementData(player, "mycarmustang")) --destroys the car, you can change "mycarmustang" to whatever you want end --finalizes what happens if the element already exists outputChatBox("Welcome, "..account.."!.", player, 0, 255, 0, false) --displays to the player a text, you can remove this if you don´t want to show anything outputChatBox("Here is your car! Have fun!", player, 0, 255, 0, false) --displays one more text to the player local x,y,z = getElementPosition(player) --gets the X, Y and Z of the player and stores it in a variable local rotX, rotY, rotZ = getElementRotation(player) -- gets the rotation of the player and stores it in a variable local veh = createVehicle("602",x,y +-2,z +2) --creates the vehicle with id 602 (alpha), what you see at the end of z, makes the vehicle spawn a little bit over the ground, it can sometimes bug on the floor if not, see complete vehicle ID´s at [url=https://wiki.multitheftauto.com/wiki/Vehicle_IDs]https://wiki.multitheftauto.com/wiki/Vehicle_IDs[/url] setElementRotation(veh,rotX,rotY,rotZ+10) --sets the vehicle rotation as the player rotation setVehicleHeadLightColor (veh,255,0,0) --sets the vehicle lights color to red, (RGB) setVehicleColor (veh,255,0,0) --sets the vehicle color to red, (RGB) --YOU CAN GENERATE COLORS ON THIS WEBSITE, [url=http://www.rapidtables.com/web/color/RGB_Color.htm]http://www.rapidtables.com/web/color/RGB_Color.htm[/url] setElementData(player, "mycarmustang", veh) --set the vehicles element to mycarmustang, if you changed the above element datas, then you must change thisone too, -- warpPedIntoVehicle(player,veh) --this is if you want to warp the player inside the vehicle one it spawns end end addEventHandler( "onPlayerQuit", getRootElement( ),function() --when player quits... if (isElement(getElementData(source, "mycarmustang"))) then --if vehicle exists destroyElement(getElementData(source, "mycarmustang")) --destroy vehicle --outputDebugString ( "1 car by Knight Destroyed." ) --just for debuging purposes end end) and you also must add the Command, lets say i want to spawn the car with the command /MyCarRed: addCommandHandler("MyCarRed",mycar) Just for you to remember, commands are CASE SENSITIVE!. So, when you type /MyCarRed, this would show up: When you type /MyCarRed for the second time, your old vehicle will disappear, if you dont want this to happen, just delete or comment out this lines (add "--" at the beggining of the line): if (isElement(getElementData(player, "mycarmustang"))) then destroyElement(getElementData(player, "mycarmustang")) end If you want to make your vehicle everything damageproof, add this: setVehicleDamageProof(veh, true) --where true means yes, if you change true to false, it will disable this. EDIT: with this modifications, instead of having to edit the LUA script, you can edit it directly from your server So lets start, first, open your meta.xml file, and paste the following: <meta> <info author="YourNickname" type="script" name="My Custom car by ACL" /> <!--This doesn´t really have to be on your script.--> <script src="car.lua" type="server" /> <!--Defines where your script is, and that it is server-sided.--> <settings> <setting name="*ACL" value="Admin" /> <!--Here you must define the ACL that can spawn the car --> </settings> </meta> Afterwards, you are going to want to edit your car.lua file, and REPLACE with the following code: function mycar(player) local account = getAccountName(getPlayerAccount(player)) local getacl = get ("ACL") if isObjectInACLGroup("user." .. account, aclGetGroup(getacl)) then if (isElement(getElementData(player, "mycarmustang"))) then destroyElement(getElementData(player, "mycarmustang")) end outputChatBox("Welcome, "..account.."!.", player, 0, 255, 0, false) outputChatBox("Here is your car! Have fun!", player, 0, 255, 0, false) local x,y,z = getElementPosition(player) local rotX, rotY, rotZ = getElementRotation(player) local veh = createVehicle("602",x,y +-4,z +2) setElementRotation(veh,rotX,rotY,rotZ+10) setVehicleHeadLightColor (veh,255,0,0) setVehicleColor (veh,255,0,0) setElementData(player, "mycarmustang", veh) -- warpPedIntoVehicle(player,veh) end end addEventHandler( "onPlayerQuit", getRootElement( ),function() if (isElement(getElementData(source, "mycarmustang"))) then destroyElement(getElementData(source, "mycarmustang")) end end) And the command: addCommandHandler("mycar",mycar) --command would be /mycar So, you can edit the account that can use the vehicle by 2 methods: 1.) By editing the XML: You can edit the XML and edit value="admin" to the account name you want to use, for example: <!--<setting name="*Account" value="admin" />--> <!--OLD ACCOUNT--> <setting name="*ACL" value="MyACL" /> <!--MY NEW ACCOUNT--> 2.) By editing the option on your admin panel: For this, you will need to have the resource ADMIN started on your server, afterwards, press letter P to start your admin panel, you will see something like this: You will want to go to the tab named Resources, and you will see a searchbox, in which you will type in the name of the folder you created, remember to move your folder to the server´s resources folder, once you search for your folder´s name, you will see something like this: By double clicking it, you will see something like this: Once you are here, you want to double click the field "ACL", and you will see a textbox like thisone: Just replace the content with the account name you want, and click OK, then restart the resource by clicking "Restart", you can see it located here: If your resource shows up like "loaded", click on Start, if your resource shows up like "running", click on Restart. So that would be it! Thanks for visiting my post!
  17. It can be as needed, currently is server-sided. Thanks
  18. What do you mean with Hazard Lights?
  19. Hello, im using Al3grab (https://community.multitheftauto.com/in ... ls&id=6911) It doesn´t have a clan blip system, and I want to add id, so i have this code: function gps() local group = getElementData(source,"Group") if group == "N/A" then return end local name = getPlayerName(source) thePlayer = getPlayerFromName ( name ) for k,v in ipairs ( getElementsByType("player") ) do local g = getElementData(v,"Group") if g == group then local myBlip = createBlipAttachedTo (thePlayer, 52) player_blips[source] = blip --setElementVisibleTo (myBlip, v, true ) end end end addEventHandler ("onPlayerLogin", getRootElement(),gps) And I want the blip to: 1.) Only be visible to clan members 2.) Disappear when player quits I have tried many ways, but each time i get different erros, so I give up haha , Thanks.
  20. Alright, i found this script on the MTA resources page (https://community.multitheftauto.com/in ... ls&id=3472) And it is working, except for 1 think, it is not showing the deaths on the table, and it shows no errors on the debugscript, here is the code if its easier for you: addEventHandler ( "onPlayerWasted", root, function( totalAmmo, killer, killerWeapon, bodypart, stealth ) if killer then local account = getPlayerAccount ( killer ) if killer ~= source then setAccountData( account,"totalkillsdeaths.Kills",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) +1 ) setElementData( killer, "T/K", tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) ) ) end else local accountSource = getPlayerAccount ( source ) setAccountData( accountSource,"totalkillsdeaths.Deaths",tonumber( getAccountData(accountSource,"totalkillsdeaths.Deaths") or 0 ) +1 ) setElementData( source, "T/D", tonumber( getAccountData( accountSource,"totalkillsdeaths.Deaths" ) ) ) end end ) addEventHandler( "onPlayerLogin",root, function( thePreviousAccount, theCurrentAccount, autoLogin ) local account = getPlayerAccount ( source ) if not getAccountData( account,"totalkillsdeaths.Kills" ) and not getAccountData( account,"totalkillsdeaths.Deaths" ) then setAccountData( account,"totalkillsdeaths.Kills",0 ) setAccountData( account,"totalkillsdeaths.Deaths",0 ) end setElementData( source,"T/D",tonumber( getAccountData( account,"totalkillsdeaths.Deaths" ) or 0 ) ) setElementData( source,"T/K",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) ) end ) addEventHandler( "onResourceStart",resourceRoot, function( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/K",root,2, 0.035 ) ) ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/D",root,3, 0.035 ) ) ) end ) Thanks
  21. Hello, im trying to create a table where the players kills and deaths are saved, using this: function playercreatekillsdeaths() if not getElementData(source,"kills") then setElementData(source,"kills",0) outputDebugString("testing") end if not getElementData(source,"deaths") then setElementData(source,"deaths",0) outputDebugString("testing") end end addEventHandler("onPlayerLogin", getRootElement(), playercreatekillsdeaths) To record when the player is killed im trying to use this: function onplayerkilledplayer(source) thePlayer = getPlayerFromName (source) local count = getElementData(thePlayer,"kills") setElementData(thePlayer,"kills",count+1) end addEventHandler("onPlayerWasted", getRootElement(), onplayerkilledplayer) I really dont know how to achieve this. Thanks
  22. Hello Killeryoyo, what setFarClipDistance does is that it sets the whole server view distance, lets say if i set it to 10000, i can see the AREA51 mountains from the LS-LV bridge, what i want to do is to create a command that makes setFarClipDistance to only 1 person, lets say i have a high-end PC and want longer view distance.
  23. Hello, im trying to make a command to set view distance for the person who executed the command, i checked the wiki and it doesnt show there is an argument to set it to 1 client, my current code is the following: function viewdis() setFarClipDistance(5000) -- We adjust visibility range to 3000 metres end addCommandHandler("view1",viewdis) thanks guys
  24. Thank you, i solved the problem, i had my "SetCameraTarget" timer way to high (15000)... Thanks guys.
×
×
  • Create New...