Jump to content

getPickup Type error


^Dev-PoinT^

Recommended Posts

Posted

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:

Posted

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

Posted

iam not good scripter like you are iam new in script :(

i have errors in the smallest scripts like outputChatBox and colors and ....

so if you can help me with it please stand there and do nothing :)

Posted

Honestly, you are stupid as hell, these kind of errors are so easy to fix.(I didn't readed the whole code anyway)

From

thePlayer ) 

to

thePlayer 

Posted

He just need to learn and dont call him stupid cuz stupid as hell when i hear that i think of people who dont know how to open a door lolz but anyway thisn is going offtopic dev feel free to pm me again if you need help :D

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

Dev Point what do you think about this?

there are 3 errors can you see it?

Posted
outputChatBox(  " You Have Picked up a ".. [here your variable for type], thePlayer, getRootElement(), 255, 255, 0 ) 

wrong wrong wrong wrong wrong wrong wrong wrong wrong wrong wrong wrong wrong

Posted
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

Now you can see the error. Fix it, gogogo!

Posted
i dont get you Benxamix2 :)

Joined:

Sun Oct 02, 2011 7:33 am

Total posts:

258 | Search user’s posts

(0.08% of all posts / 5.16 posts per day)

That pretty much says it all doesn't it? :?

Posted

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 ) 

Posted

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

Posted
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.

Posted

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) 

Posted (edited)
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

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...