AddPlayerClothes: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Added template)
mNo edit summary
Line 20: Line 20:
This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.
This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onEnterVehicle ( vehicle, seat, jacked )
function onEnterVehicle ( theVehicle, seat, jacked )
   if ( getVehicleID ( vehicle ) == 522 ) then -- if its a nrg
   if ( getVehicleID ( theVehicle ) == 522 ) then     -- if it's an nrg
     addPlayerClothes ( source, "moto", "moto", 16 ) -- add the helmet
     addPlayerClothes ( source, "moto", "moto", 16 )   -- add the helmet
   end
   end
end
end
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), onEnterVehicle )
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), onEnterVehicle )


function onExitVehicle ( vehicle, seat, jacked )
function onExitVehicle ( theVehicle, seat, jacked )
   if ( getVehicleID ( vehicle ) == 522 ) then -- if its a nrg
   if ( getVehicleID ( theVehicle ) == 522 ) then     -- if it's an nrg
     removePlayerClothes ( source, 16 ) -- remove the helmet
     removePlayerClothes ( source, 16 )               -- remove the helmet
   end
   end
end
end

Revision as of 14:46, 21 August 2007

This function is used to set the current clothes of a certain type on a player. It can only be used on players with the CJ skin (id 0).

Syntax

bool addPlayerClothes ( player thePlayer, string clothesTexture, string clothesModel, int clothesType )

Required Arguments

  • thePlayer: The player whose clothes you want to change.
  • clothesTexture: A string determining the clothes texture that will be added. See clothes textures.
  • clothesModel: A string determining the clothes model that will be added. See clothes models.
  • clothesType: A integer representing the clothes slot/type the clothes should be added to.

Returns

This function returns 'true' if the clothes were successfully added to the player, 'false' otherwise.

Example

This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.

function onEnterVehicle ( theVehicle, seat, jacked )
  if ( getVehicleID ( theVehicle ) == 522 ) then      -- if it's an nrg
    addPlayerClothes ( source, "moto", "moto", 16 )   -- add the helmet
  end
end
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), onEnterVehicle )

function onExitVehicle ( theVehicle, seat, jacked )
  if ( getVehicleID ( theVehicle ) == 522 ) then      -- if it's an nrg
    removePlayerClothes ( source, 16 )                -- remove the helmet
  end
end
addEventHandler ( "onPlayerExitVehicle", getRootElement(), onExitVehicle )

See Also