SA-MP Forums Archive
Help me! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help me! (/showthread.php?tid=613025)



Help me! - Fantje - 23.07.2016

Hey guy.

I made a money drop.

So if a player dies it will drup 5 cash pickups and each pickup will give the player 100$ cash.

My problem: The player walks in the pickups and they will be gone. If the player respawns the pickups will appear again.

How to fix that the pickups will stay gone after a player picked it up?

Codes:
PHP код:
public OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == cash)
    {
        
GivePlayerMoney(playerid,100);
    }
    else if(
pickupid == cash2)
    {
        
GivePlayerMoney(playerid,100);
    }
    else if(
pickupid == cash3)
    {
        
GivePlayerMoney(playerid,100);
    }
    else if(
pickupid == cash4)
    {
        
GivePlayerMoney(playerid,100);
    }
    else if(
pickupid == cash5)
    {
        
GivePlayerMoney(playerid,100);
    }
    return 
1;

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    new 
Float:x,Float:y,Float:z;
    
ResetPlayerMoney(playerid);
      
GetPlayerPos(playerid,x,y,z);
    
cash CreatePickup(1212,8,x,y,z);
    
cash2 CreatePickup(1212,8,x+1,y,z);
    
cash3 CreatePickup(1212,8,x-1,y,z);
    
cash4 CreatePickup(1212,8,x,y+1,z);
    
cash5 CreatePickup(1212,8,x,y-1,z);

Please help me


Re: Help me! - Fantje - 23.07.2016

Anyone knows why the pickup comes back?


Re: Help me! - Rockefeller - 23.07.2016

DestroyPickup(pickupname);


Re: Help me! - Fantje - 23.07.2016

Thank you!


Re: Help me! - Dayrion - 24.07.2016

Parameters of CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld)
Set type to 3 : Disappears after pickup, respawns after death.
By the way you can optimize your code.
PHP код:
public OnPlayerPickUpPickup(playeridpickupid
{
    switch(
pickid)
    {
        case 
cash GivePlayerMoney(playerid,100); 
        case 
cash2 GivePlayerMoney(playerid,100); 
        
        case 
cash3 GivePlayerMoney(playerid,100); 
        
        case 
cash4 GivePlayerMoney(playerid,100); 
        case 
cash5 GivePlayerMoney(playerid,100); 
    }
    return 
1