manve1 Posted September 29, 2012 Posted September 29, 2012 would there be a way i could make my script blow someones vehicles when i do: /boom ? function ( player ) local vehicle = getPedOccupiedVehicle ( player ) if ( vehicle ) then if ( boom ) then blowVehicle ( vehicle ) end end end Looking for tutorials or information? check out: www.simpleask.co.uk
Jaysds1 Posted September 29, 2012 Posted September 29, 2012 ya, try this: function power(source,action,player) player = getPlayerFromName(player) if not player then outputChatBox("sorry, but we need the player full name!",source) return end if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!",source) return end local vehicle = getPedOccupiedVehicle ( player ) if ( action == "fix" ) then fixVehicle ( vehicle ) elseif ( action == "blow" ) then blowVehicle ( vehicle ) end end addCommandHandler("blow",power) addCommandHandler("fix",power) oh, server-side BTW, unless you want it client-side try this: function power(action,player) player = getPlayerFromName(player) if not player then outputChatBox("sorry, but we need the player full name!") return end if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!") return end local vehicle = getPedOccupiedVehicle ( player ) if ( action == "fix" ) then fixVehicle ( vehicle ) elseif ( action == "blow" ) then blowVehicle ( vehicle ) end end addCommandHandler("blow",power) addCommandHandler("fix",power) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
manve1 Posted September 29, 2012 Author Posted September 29, 2012 dont work no output or anything Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted September 29, 2012 Posted September 29, 2012 You may want to use getPlayerFromNamePart from Wiki's Useful Functions. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Jaysds1 Posted September 29, 2012 Posted September 29, 2012 dont work no output or anything They should work, which one did you try? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
manve1 Posted September 29, 2012 Author Posted September 29, 2012 i tried blow fix dont work too Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted September 29, 2012 Posted September 29, 2012 dont work no output or anything They should work, which one did you try? It will never work because you used getPlayerFromName which will only work if you write the full name ( with color codes ). "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted September 29, 2012 Author Posted September 29, 2012 Anderl code looks like this: function power(source,action,player) player = getPlayerFromNamePart(player) if not player then outputChatBox("sorry, but we need the player full name!",source) return end if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!",source) return end local vehicle = getPedOccupiedVehicle ( player ) if ( action == "fix" ) then fixVehicle ( vehicle ) elseif ( action == "blow" ) then blowVehicle ( vehicle ) end end addCommandHandler("blow",power) addCommandHandler("fix",power) Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted September 29, 2012 Posted September 29, 2012 getPlayerFromNamePart is a function made by users, not a built-in MTA:SA function. https://wiki.multitheftauto.com/wiki/Get ... omNamePart "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted September 29, 2012 Author Posted September 29, 2012 oh, got confused now confused of how should i make the getPlayerFromNamePart EDIT: i tried making it work .. but failed: function power(source,action,player) player = getPlayerName( source ) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end if not player then outputChatBox("sorry, but we need the player full name!",source) return end if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!",source) return end local vehicle = getPedOccupiedVehicle ( player ) if ( action == "fix" ) then fixVehicle ( vehicle ) elseif ( action == "blow" ) then blowVehicle ( vehicle ) end end end addCommandHandler("blow",power) addCommandHandler("fix",power) Looking for tutorials or information? check out: www.simpleask.co.uk
manve1 Posted September 29, 2012 Author Posted September 29, 2012 there is no errors ... Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted September 29, 2012 Posted September 29, 2012 oh, got confused nowconfused of how should i make the getPlayerFromNamePart EDIT: i tried making it work .. but failed: function power(source,action,player) player = getPlayerName( source ) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end if not player then outputChatBox("sorry, but we need the player full name!",source) return end if not isPedInVehicle(player) then outputChatBox("Sorry, but the player isn't in a vehicle!",source) return end local vehicle = getPedOccupiedVehicle ( player ) if ( action == "fix" ) then fixVehicle ( vehicle ) elseif ( action == "blow" ) then blowVehicle ( vehicle ) end end end addCommandHandler("blow",power) addCommandHandler("fix",power) Your code makes totally no sense. Is it that hard to copy a function to your code? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Cadu12 Posted September 30, 2012 Posted September 30, 2012 function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end function onPlayerCommands ( source, cmd, target ) local targetplayer = getPlayerFromNamePart ( target ) if ( targetplayer ) then local vehicle = getPedOccupiedVehicle ( targetplayer ) if ( vehicle ) then if ( cmd == "blow" ) then blowVehicle ( vehicle ) elseif ( cmd == "fix" ) then fixVehicle ( vehicle ) end end end end addCommandHandler ( "blow", onPlayerCommands ) addCommandHandler ( "fix", onPlayerCommands ) Try that, untested. Ingame nick: Cadu12
manve1 Posted September 30, 2012 Author Posted September 30, 2012 fix works, blow doesn't Looking for tutorials or information? check out: www.simpleask.co.uk
TAPL Posted September 30, 2012 Posted September 30, 2012 fix works, blow doesn't This problem from ACL You will find this in ACL "command.blow" access="false"> change it to "command.blow" access="true">
manve1 Posted September 30, 2012 Author Posted September 30, 2012 k, thanx Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted September 30, 2012 Posted September 30, 2012 fix works, blow doesn't This problem from ACL You will find this in ACL "command.blow" access="false"> change it to "command.blow" access="true"> That's for admin panel blow command, it has nothing to do with blow function. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
manve1 Posted September 30, 2012 Author Posted September 30, 2012 i realized that ... Looking for tutorials or information? check out: www.simpleask.co.uk
TAPL Posted September 30, 2012 Posted September 30, 2012 fix works, blow doesn't This problem from ACL You will find this in ACL "command.blow" access="false"> change it to "command.blow" access="true"> That's for admin panel blow command, it has nothing to do with blow function. I haven't say this has anything to do with blow function, it's about the command itself. if the command was blocked in ACL, you will not be able to use it without right, that is the reason why the script doesn't blow the vehicle.
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