SetPickupType: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Category:Incomplete]]
[[Category:Needs Checking]] 
'''This is a pretty useless function if we cant set the data for the pickup.
It should be:
int getPickupType ( pickup, amount/weapon, [ammo] )
There is no point in setting a pickup into a Weapon, for example, if you cant set what weapon you want or the ammo.'''
--[[User:Talidan2|Talidan2]] 14:53, 12 August 2006 (CDT)
__NOTOC__  
__NOTOC__  
VALUES: 0 - health 1 - armor 2 - weapon
This function allows the setting of a pickup to a Weapon, Armour or Health pickup, and allows you to set the health points '''or''' the weapon and ammo


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getPickupType ( pickup pickup )           
setPickupType ( pickup, type, int amount/weapon, [ int ammo ] )           
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''pickup:''' The pickup in which you wish to change the settings of
* '''type''': This is an integer representing the type of pickup, representing the following types:
** '''0''': Health Pickup
** '''1''': Armour Pickup
** '''2''': Weapon Pickup
* '''amount/weapon''': This is an integer representing the amount of Health points or Armour points a pickup has.  If the type is a Weapon pickup, then it represents the Weapon ID of the weapon pickup the 'ammo' field must be entered if the type is Weapon Pickup.


===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''argumentName2:''' descriptiona
*'''ammo''': An integer representing the amount of ammo a pickup contains.  This is only valid when the pickup type is a Weapon Pickup, and must be entered.
*'''argumentName3:''' description
 
===Returns===
Returns ''true'' if blah, ''false'' otherwise.


==Example==  
==Example==  
This example does...
This example changes the pickup time every time someone hits it
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
addEventHandler ( onPickupHit, root, onPickupHit ) --add an event handler for onPickupHit
blabhalbalhb --abababa
function onPickupHit --when a pickup is hit
--This line does this...
    currenttype = getPickupType ( source ) --define the current type of pickup as currenttype
mooo
    if currenttype == 0 then --if it is currently a health pickup
        setPickupType ( source, 1, 100 ) --change it to an armour pickup with 100 hp
    elseif currenttype == 1 then --else, if it is currently an armour pickup
        setPickupType ( source, 2, 29, 100 ) --change it to an mp5 weapon pickup with 100 ammo
    elseif currenttype == 2 then --lastly, if it is already a weapon
        setPickupType ( source 0, 100 ) --change it to a health pickup
    end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Pickup functions}}

Revision as of 01:06, 13 August 2006

This function allows the setting of a pickup to a Weapon, Armour or Health pickup, and allows you to set the health points or the weapon and ammo

Syntax

setPickupType ( pickup, type, int amount/weapon, [ int ammo ] )          

Required Arguments

  • pickup: The pickup in which you wish to change the settings of
  • type: This is an integer representing the type of pickup, representing the following types:
    • 0: Health Pickup
    • 1: Armour Pickup
    • 2: Weapon Pickup
  • amount/weapon: This is an integer representing the amount of Health points or Armour points a pickup has. If the type is a Weapon pickup, then it represents the Weapon ID of the weapon pickup the 'ammo' field must be entered if the type is Weapon Pickup.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • ammo: An integer representing the amount of ammo a pickup contains. This is only valid when the pickup type is a Weapon Pickup, and must be entered.

Example

This example changes the pickup time every time someone hits it

addEventHandler ( onPickupHit, root, onPickupHit ) --add an event handler for onPickupHit
function onPickupHit --when a pickup is hit
    currenttype = getPickupType ( source ) --define the current type of pickup as currenttype
    if currenttype == 0 then --if it is currently a health pickup
        setPickupType ( source, 1, 100 ) --change it to an armour pickup with 100 hp
    elseif currenttype == 1 then --else, if it is currently an armour pickup
        setPickupType ( source, 2, 29, 100 ) --change it to an mp5 weapon pickup with 100 ammo
    elseif currenttype == 2 then --lastly, if it is already a weapon
        setPickupType ( source 0, 100 ) --change it to a health pickup
    end
end

See Also