TroyBoy Posted February 21, 2012 Share Posted February 21, 2012 i have that script that if i write sethp and a playername and hp its set the player i write the hp i want but i want that if i will not write a player name it will set hp to me here the command: addCommandHandler( "setphp", function( player,_,name ) local theHealth = tonumber(theHealth) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local find = findPlayer( name ) if not find then outputChatBox ( "No player with that name." ) else if (theHealth) then setElementHealth( find, theHealth ) end end end end end ) please help me Link to comment
Kenix Posted February 21, 2012 Share Posted February 21, 2012 Server addCommandHandler( "setphp", function( player,_,thePlayer,theHealth ) if thePlayer and theHealth then local theHealth = tonumber( theHealth ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local find = findPlayer( thePlayer ) if not find then find = player end if theHealth then setElementHealth( find, theHealth ) end end end else outputChatBox( '/setphp [player name][amount]',player,255,0,0 ) end end ) So if player not found then set health you. Link to comment
TroyBoy Posted February 21, 2012 Author Share Posted February 21, 2012 can i do that only if he not write a player name it will set the hp to him not when its not find the player i mean if he will do /sethp 50 it will set is hp 50 but if he will do /sethp [playername] 50 it will set the player he choose 50 hp Link to comment
Kenix Posted February 21, 2012 Share Posted February 21, 2012 function isNumber( value ) if type( value ) == 'string' then if tonumber( value ) then return true end return false end return false end addCommandHandler( "setphp", function( player,_,arg1,arg2 ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local health,find if isNumber( arg1 ) and not arg2 then health = tonumber( arg1 ) find = player elseif arg1 and isNumber( arg2 ) then health = tonumber( arg2 ) local finded = findPlayer( arg1 ) if finded then find = finded else find = false end end if find then setElementHealth( find, health ) else outputChatBox( 'Player not found use: /setphp [amount] or /setphp [player name][amount]',player,255,0,0 ) end end end end ) Updated. Link to comment
TroyBoy Posted February 21, 2012 Author Share Posted February 21, 2012 when i do /setphp 50 it doesnt set my hp to 50 Link to comment
Kenix Posted February 21, 2012 Share Posted February 21, 2012 Server function isNumber( value ) if type( value ) == 'string' then if value:find( '^[0-9]' ) then return true end return false end return false end function findPlayer(namepart) local player = getPlayerFromName(namepart) if player then return player end for _,player in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), namepart:lower(), 1, true) then return player end end return false end addCommandHandler( "setphp", function( player,_,arg1,arg2 ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local health,find if isNumber( arg1 ) and not arg2 then health = tonumber( arg1 ) find = player elseif arg1 and isNumber( arg2 ) then health = tonumber( arg2 ) local finded = findPlayer( arg1 ) if finded then find = finded else find = false end end if find then setElementHealth( find, health ) else outputChatBox( 'Player not found use: /setphp [amount] or /setphp [player name][amount]',player,255,0,0 ) end end end end ) Full code. Tested. cmd /setphp Link to comment
TroyBoy Posted February 21, 2012 Author Share Posted February 21, 2012 (edited) i have problem with this command its not set my position z +5: addCommandHandler( "flip", function ( player,vehicle ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local x,y,z = getElementPosition( player ) setElementPosition ( vehicle, x, y, z + 5 ) end end end ) Edited February 21, 2012 by Guest Link to comment
Evil-Cod3r Posted February 21, 2012 Share Posted February 21, 2012 addCommandHandler( "flip", function ( player, cmd ) local playerTeam = getPlayerTeam ( player ) local veh = getPedOccupiedVehicle(player) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local x,y,z = getElementPosition( player ) setElementPosition ( veh, x, y, z + 5 ) end end end ) Link to comment
Kenix Posted February 21, 2012 Share Posted February 21, 2012 You need rotate vehicle ( not set position ). Link to comment
denny199 Posted February 21, 2012 Share Posted February 21, 2012 addCommandHandler( "flip", function ( player,vehicle ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local vehicle = getPedOccupiedVehicle ( player ) local x,y,z = getElementPosition( vehicle ) setElementPosition ( vehicle, x, y, z + 5 ) end end end ) Link to comment
Scooby Posted February 21, 2012 Share Posted February 21, 2012 what u have wont flip the car, it'll just lift it by 5. to flip it use: local x,y,z = getElementRotation(vehicle) setElementRotation (vehicle,x,y + 180,z) 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