Jump to content

getPickup Type error


^Dev-PoinT^

Recommended Posts

Hi all its work fine but the msg dont show

You Have Picked up a ..

function Health ( totalammo, killer, killerweapon, bodypart ) 
       local  x, y, z = getElementPosition ( source ) 
       local  health = createPickup ( x, y, z, 0, 40) 
       addEventHandler("onPickupHit", health, Health) 
    end 
    addEventHandler ( "onPlayerWasted", getRootElement(), createDeathPickup ) 
      
    function Health (thePlayer) 
        setElementHealth(thePlayer,tonumber(getElementHealth(thePlayer))+tonumber(getPickupAmount(source))) 
        destroyElement(source) 
    end 
    
    function onPickupHitShow ( thePlayer )                                                         
    local a = getPickupType ( source )           
    if (a == 0) then 
    outputChatBox(.. a " You Have Picked up.. ", thePlayer ), getRootElement(), 255, 255, 0, true) 
addEventHandler ( "onPickupHit", getRootElement(), onPickupHitShow ) 

i tryed over 10 time fix it but always get an errors :oops:

Link to comment

ok lol you pmed me with this and i fixed the shit wich was wrong so it worked then you got a problem with the msg and gave me the debug error and it said unexpected sysmbol at line 16 so i said just go to line 16 and look you will find the symbol wich shouldnt be there i guess

Link to comment

Try

function Health ( totalammo, killer, killerweapon, bodypart ) 
    local  x, y, z = getElementPosition ( source ) 
    local  health = createPickup ( x, y, z, 0, 40) 
    addEventHandler("onPickupHit", health, Health) 
end 
addEventHandler ( "onPlayerWasted", root, createDeathPickup ) 
     
function Health  ( thePlayer ) 
    setElementHealth( thePlayer,tonumber(getElementHealth(thePlayer))+tonumber(getPickupAmount(source)) ) 
    destroyElement( source ) 
end 
    
function onPickupHitShow ( thePlayer )                                                         
    local a = getPickupType ( source )           
    if a == 0 then 
        outputChatBox( a.." You Have Picked up.. ", thePlayer , root, 255, 255, 0, true ) 
    end 
end 
addEventHandler ( "onPickupHit", root, onPickupHitShow ) 

Link to comment
omg noobs :o

+1

TO EVERYONE:

Returns

Returns ''false'' if the pickup is invalid, or an integer of the type of the pickup, which include:

0: Health pickup

1: Armour pickup

2: Weapon pickup

This says that we cannot use getPickupType as a string, because it returns A NUMBER. So to show it properly you must use

tostring(a)

To show you this text on chat: "You have picked up a 0".

But it's still wrong, right?

Using tables you can set the number mean "something".

names = { [0]="something", [1]="anotherThing", [2]="andSomethingElse" }

So it will show "You have picked up a something" in the case of a health pickup. Now, go fix it!

ALSO WHAT MICHAEL SAID RIGHT ABOVE ME. CHECK IT

PD. I think dev needs seriously to FOCUS ON WHAT HE'S DOING. His script is completely nonsense.

Link to comment

13 lines - 5 minute script. Read the comments.

 --This function is executed when the health pickup is used - it destroys the pickup. 
--NOTE: there is no need to call setElementHealth as pickups handle this automatically. 
local function onHealthPickupUse(thePlayer) 
    destroyElement(source) 
end 
  
--This function is executed when a player dies - it creates a health pickup where they died. 
local function playerDeath() 
    local posX, posY, posZ = getElementPosition(source) 
    local healthPickup = createPickup(posX, posY, posZ, 0, 40) 
    addEventHandler("onPickupUse", healthPickup, onHealthPickupUse) 
end 
addEventHandler("onPlayerWasted", root, playerDeath) 

Link to comment
Kenix, you too did the same thing ><

wtf?

outputChatBox( a.." You Have Picked up.. ", thePlayer , root, 255, 255, 0, true ) 

wtf is this?

thePlayer , root 

omg noobs :o

oh I did not notice it.

all can be wrong.

This correct

  
local tPickups = {  -- table Pickups type 
    [0] = "Health", 
    [1] = "Armour", 
    [2] = "Weapon" 
} 
  
addEventHandler ( "onPlayerWasted", root, -- add handler if player die 
    function( totalammo, killer, killerweapon, bodypart ) 
        local  x, y, z = getElementPosition ( source ) -- get position "die player" 
        local  health = createPickup ( x, y, z, 0, 40 ) -- it's create health pickup in position die player.. 
        addEventHandler( "onPickupHit", health,  -- add handler if Pickup Hit 
            function ( thePlayer ) -- thePlayer is player, source is pickup 
                outputChatBox( " You Have Picked up.. "..tPickups[ getPickupType ( source ) ], thePlayer, 255, 255, 0, true )  -- print it 
                destroyElement( source ) -- destroy Pickup 
            end 
        )    
    end 
) 

Edited by Guest
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...