manve1 Posted September 29, 2012 Share 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 Link to comment
Jaysds1 Posted September 29, 2012 Share 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) Link to comment
manve1 Posted September 29, 2012 Author Share Posted September 29, 2012 dont work no output or anything Link to comment
Anderl Posted September 29, 2012 Share Posted September 29, 2012 You may want to use getPlayerFromNamePart from Wiki's Useful Functions. Link to comment
Jaysds1 Posted September 29, 2012 Share Posted September 29, 2012 dont work no output or anything They should work, which one did you try? Link to comment
manve1 Posted September 29, 2012 Author Share Posted September 29, 2012 i tried blow fix dont work too Link to comment
Anderl Posted September 29, 2012 Share 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 ). Link to comment
manve1 Posted September 29, 2012 Author Share 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) Link to comment
Anderl Posted September 29, 2012 Share 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 Link to comment
manve1 Posted September 29, 2012 Author Share 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) Link to comment
Mossy Posted September 29, 2012 Share Posted September 29, 2012 What error do you get in the debug? Link to comment
manve1 Posted September 29, 2012 Author Share Posted September 29, 2012 there is no errors ... Link to comment
Anderl Posted September 29, 2012 Share 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? Link to comment
Cadu12 Posted September 30, 2012 Share 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. Link to comment
manve1 Posted September 30, 2012 Author Share Posted September 30, 2012 fix works, blow doesn't Link to comment
TAPL Posted September 30, 2012 Share 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"> Link to comment
Anderl Posted September 30, 2012 Share 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. Link to comment
manve1 Posted September 30, 2012 Author Share Posted September 30, 2012 i realized that ... Link to comment
TAPL Posted September 30, 2012 Share 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. 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