Jump to content

Send armor To [ID] [HELP]


PaulDK

Recommended Posts

i want to send armor in (id) but i can't ... here's the script ...

Thanks in Advance :D

--------->

function giveArmor ( p1, _, p2, id )

for _, group in ipairs ({"Admin", "Supermoderator","Console","Moderator"}) do

local playerAccount = getPlayerAccount(p1)

if (not playerAccount) then return end

local accountName = getAccountName(playerAccount)

if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( group ) ) then

if p2 then

if tonumber(id) then

target = getPlayerFromID(tonumber(p2))

else

target = getPlayerFromName(p2)

end

setPedArmor(target, 100)

outputChatBox("Given Armor", source, 255, 255, 255, true)

return false

end

end

end

end

addCommandHandler("armor", giveArmor)

Link to comment
getPlayerFromID(...) 

Is not a MTA function.

if tonumber(id) then 
target = getPlayerFromID(tonumber(p2)) 
else 
target = getPlayerFromName(p2) 
end 

Sense?

but it's my first time doing in Giving in ID So I need help :roll:

--------->

function giveArmor ( p1, _, p2, id, command )

for _, group in ipairs ({"Admin", "Supermoderator","Console","Moderator"}) do

local playerAccount = getPlayerAccount(p1)

if (not playerAccount) then return end

local accountName = getAccountName(playerAccount)

if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( group ) ) then

if p2 then

if id then

id = tonumber(p2)

target = getPlayerByID(id)

else

target = getPlayerFromName(p2)

end

setPedArmor(target, 100)

outputChatBox("Given Armor", source, 255, 255, 255, true)

return false

end

end

end

end

addCommandHandler("armor", giveArmor)

Link to comment
First of all your from DK?

Next, there is no ID in MTA. So unless you had somewhere set the ID of the player then you cant do that stuff..

use getPlayerFromName instead, it finds the player element based on the name.

I Have ID Script i just need to create how to give player in id ... :wink:

Link to comment

If this ID script works by setting element data 'id' to the actual player ID, add this function at the top of the file:

function getPlayerFromID(id) 
  for k,v in ipairs(getElementsByType("player")) do 
    if getElementData(v, "id") == id then 
      return v 
    end 
  end 
  return false 
end 

Returns player element if found by ID, or false otherwise

Link to comment
If this ID script works by setting element data 'id' to the actual player ID, add this function at the top of the file:
function getPlayerFromID(id) 
  for k,v in ipairs(getElementsByType("player")) do 
    if getElementData(v, "id") == id then 
      return v 
    end 
  end 
  return false 
end 

Returns player element if found by ID, or false otherwise

No Works ... always ID was not Found :roll:

this is the Script

------>

function getPlayerFromID ( id )

for k, player in ipairs ( getElementsByType ( "player" ) ) do

local p_id = getElementData ( player, "id" )

if ( p_id == tonumber(id) ) then

player_n = getPlayerName ( player )

return player, player_n

end

end

return false, "No player has been found with the ID " .. id .. "."

end

function giveArmor ( p1, _, p2, id)

for _, group in ipairs ({"Admin", "Supermoderator","Console","Moderator"}) do

local playerAccount = getPlayerAccount(p1)

if (not playerAccount) then return end

local accountName = getAccountName(playerAccount)

if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( group ) ) then

if p2 then

local targetz = getPlayerFromName(p2)

if p2 then

local targetz = getPlayerFromName ( p2 )

if targetz then

local ID = tonumber(p2)

if ID then

target = getPlayerFromID(ID)

else

target = getPlayerFromName(p2)

end

local xplayer = getPlayerName ( p1 )

setPedArmor ( target, 100 )

outputChatBox ("#00FFFF[sERVER] "..xplayer.." #00FFFFgave you Armor.", ej, 255, 255, 255, true )

end

else

outputChatBox("#00FFFF[sERVER] #FF0000id or name are invalid ! ", p1, 255, 255, 255, true)

end

else

outputChatBox("#00FFFF[sERVER] Please Use /givearmor [ id or name]", p1, 255, 255, 255, true)

end

end

end

end

addCommandHandler ( "givearmor", giveArmor )

ANYONE PRO SCRIPTER HELP MEEEEE PLEASEEEEEEEEEE ! :?:?:?

TO DONE THIS CRAZY THINGS ! :cry::cry::cry:

TAPL Max+ Citizen Please Helppppp meeeeeee ! :?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...