damien111 Posted August 18, 2012 Share Posted August 18, 2012 I need help with making it so when a player is hit with a nightstick and his wlevel is higher than 0 he is sent to the jail for 10seconds * wlevel. . doesnt matter who hits them with the nightstick, cause nighstick will be a police only weapon. sso can anyone help? Also. How can i make it so peoples money is saved, off topic but it will help me Thanks Link to comment
AMARANT Posted August 18, 2012 Share Posted August 18, 2012 There's a nice script which can help you in the beginning until you learn how to make your own. https://community.multitheftauto.com/index.php?p=resources&s=details&id=292 Link to comment
damien111 Posted August 18, 2012 Author Share Posted August 18, 2012 I cant get it to work Do you know any scripts that have the hitting with nightstick, then warping the suspect kind of scripts i can look at? i just need to learn how it works Link to comment
AMARANT Posted August 18, 2012 Share Posted August 18, 2012 This script is exactly the thing you need. You can check the code especially as because it has lines with comments. Link to comment
Flaker Posted August 18, 2012 Share Posted August 18, 2012 Example of code: --CLIENT SIDE addEventHandler("onClientPlayerDamage", localPlayer, function (attacker, weapon) if (attacker and source ~= attacker) then if (getElementType ( attacker ) == "player") then if ( weapon == 3 and getTeamName(getPlayerTeam(attacker)) == "Police" ) then local SourceWantedLevel = getPlayerWantedLevel() if ( SourceWantedLevel > 0 ) then if ( getElementHealth ( source ) < 90 and getElementHealth ( source ) > 0 )then triggerServerEvent("POLICESYS:JailThePlayer", localPlayer, attacker) end end end end end end ) --SERVER SIDE addEvent("POLICESYS:JailThePlayer",true) addEventHandler("POLICESYS:JailThePlayer",root, function (attacker) local x = 1 local y = 1 local z = 1 givePlayerMoney ( attacker, math.random(500, 1000) ) --Give money to cop setElementPosition ( source, x, y, z, true ) end ) Link to comment
damien111 Posted August 18, 2012 Author Share Posted August 18, 2012 Ah! Thanks! I love this forum! Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 Alright! Heres my code so far! It is not working, i did /debugscript 3, here are the errors if that will hep. i did not understand them : Loading script failed : POLICE5/arrest_server.lua:3 '' expected near '(' Loading script failed : POLICE5/arrest_client.lua:15 ')' expected (to close '(' at line 1) near CLIENT addEventHandler("onClientPlayerDamage", localPlayer, function (attacker, weapon) if (attacker and source ~= attacker) then if (getElementType ( attacker ) == "player") then if ( weapon == 3 and getTeamName(getPlayerTeam(attacker)) == "Police" ) then local SourceWantedLevel = getPlayerWantedLevel() if ( SourceWantedLevel > 0 ) then if ( getElementHealth ( source ) < 90 and getElementHealth ( source ) > 0 )then triggerServerEvent("POLICESYS:JailThePlayer", localPlayer, attacker) end end end end end end SERVER level = getPlayerWantedLevel ( source ) reward = 3000 function ( attacker ) local x = -4162.3032226563 local y = 1697.4566650391 local z = 1.0687500238419 givePlayerMoney ( attacker, reward ) --Give money to cop setElementPosition ( source, x, y, z, true ) setTimer ( releaseSuspect, 30000, 1 ) end addEvent("POLICESYS:JailThePlayer",true) addEventHandler("POLICESYS:JailThePlayer",root) function releaseSuspect ( ) local x = 2285.9599609375 local y = 2423.1164550781 local z = 10.8203125 setElementPosition ( source, x, y, z, true ) end Link to comment
TAPL Posted August 19, 2012 Share Posted August 19, 2012 addEventHandler("onClientPlayerDamage", localPlayer, function (attacker, weapon) if (attacker and source ~= attacker) then if (getElementType ( attacker ) == "player") then if ( weapon == 3 and getTeamName(getPlayerTeam(attacker)) == "Police" ) then local SourceWantedLevel = getPlayerWantedLevel() if ( SourceWantedLevel > 0 ) then if ( getElementHealth ( source ) < 90 and getElementHealth ( source ) > 0 )then triggerServerEvent("POLICESYS:JailThePlayer", localPlayer, attacker) end end end end end end) -- level = getPlayerWantedLevel ( source ) -- source not defined here reward = 3000 addEvent("POLICESYS:JailThePlayer",true) addEventHandler("POLICESYS:JailThePlayer",root, function ( attacker ) local x = -4162.3032226563 local y = 1697.4566650391 local z = 1.0687500238419 givePlayerMoney ( attacker, reward ) --Give money to cop setElementPosition ( source, x, y, z, true ) setTimer ( releaseSuspect, 30000, 1,source) end) function releaseSuspect(source) if not isElement(source) return end local x = 2285.9599609375 local y = 2423.1164550781 local z = 10.8203125 setElementPosition ( source, x, y, z, true ) end Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 Sorry, dont mean to be a bug but now i get this error : Warning : Loading script failed : police10/arrest_server.lua:15 'then' expected near 'return' Link to comment
TAPL Posted August 19, 2012 Share Posted August 19, 2012 lol change it to if not isElement(source) then return end Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 Thanks! Also! can you showm e how to restrict resource to ACL Groups or Teams, and, how can i turn off /kill thanks Link to comment
TAPL Posted August 19, 2012 Share Posted August 19, 2012 Thanks! Also! can you showm e how to restrict resource to ACL Groups or Teams, and, how can i turn off /kill thanks for teams this for Police, already done in your script if getTeamName(getPlayerTeam(attacker)) == "Police" then for ACL group (Admin) local accName = getAccountName(getPlayerAccount(attacker)) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then to turn off /kill you need to delete it from the script that enabled it or use this script: addEventHandler("onPlayerCommand", root, function(cmd) if cmd == "kill" then cancelEvent() end end) Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 Okay, Also! Sorry! 1 More Thing! How can i make it so a player cant deal damage? and also how to take a players gun just send me wiki pages if u want Link to comment
TAPL Posted August 19, 2012 Share Posted August 19, 2012 Okay, Also! Sorry! 1 More Thing! How can i make it so a player cant deal damage? and also how to take a players gun just send me wiki pages if u want use cancelEvent() for prevents any damage: https://wiki.multitheftauto.com/wiki/OnC ... ayerDamage if you want take one weapon: https://wiki.multitheftauto.com/wiki/TakeWeapon if you want take all weapons: https://wiki.multitheftauto.com/wiki/TakeAllWeapons Link to comment
sockz Posted August 19, 2012 Share Posted August 19, 2012 https://wiki.multitheftauto.com I''m sure you can browse the wiki by yourself Link to comment
damien111 Posted August 19, 2012 Author Share Posted August 19, 2012 I searched but couldnt find it 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