SA-MP Forums Archive
how to make DeathPickup - 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: how to make DeathPickup (/showthread.php?tid=576132)



how to make DeathPickup - FrankLucretti - 01.06.2015

Hey,

I wanted to ask how to make a DeathPickup, so if a player dies, that he leaves a pickup which stays there for 15seconds.

thx


Re: how to make DeathPickup - Greaper - 01.06.2015

Код:
new death_pickup;
forward message();

public OnPlayerDeath(playerid, killerid, reason)
{
    // Declare 3 float variables to store the X, Y and Z coordinates in
    new Float:x, Float:y, Float:z;
 
    // Use GetPlayerPos, passing the 3 float variables we just created
    GetPlayerPos(playerid, x, y, z);
 
    // Create a cash pickup at the player's position
    death_pickup = CreatePickup(1212, 4, x, y, z, -1); //Change the pickupid if you want
    SetTimer("PickupDestroy", 1000, false);
    return 1;

}

public message()
{
    //some time later...
    DestroyPickup(death_pickup);
}
Try this :\ im noob


Re: how to make DeathPickup - MafiaOink - 01.06.2015

Thats not 15 seconds its just 1 second, Here is 15 seconds and the timer is wrong



Код:
// This should be at the top under includes
new pMoneyDeath[MAX_PLAYERS];
new LastMoney;
new death_pickup;
forward messagepickup();

public OnPlayerDeath(playerid, killerid, reason)
{
    GetPlayerCash(playerid, pMoneyDeath[playerid]);
    // Declare 3 float variables to store the X, Y and Z coordinates in
    new Float:x, Float:y, Float:z;
 
    // Use GetPlayerPos, passing the 3 float variables we just created
    GetPlayerPos(playerid, x, y, z);
 
    // Create a cash pickup at the player's position
    death_pickup = CreatePickup(1212, 4, x, y, z, -1); //Change the pickupid if you want
    SetTimer("messagepickup", 15000, false);
    LastMoney = pMoneyDeath[playerid];
    return 1;

}

public messagepickup()
{
    //some time later...
    DestroyPickup(death_pickup);
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == death_pickup)
    {
        GivePlayerMoney(playerid, LastMoney);
    }
    return 1;
}
This will give the players cash when the player picksup the pickup


Re: how to make DeathPickup - FrankLucretti - 01.06.2015

Quote:
Originally Posted by MafiaOink
Посмотреть сообщение
Thats not 15 seconds its just 1 second, Here is 15 seconds and the timer is wrong



Код:
// This should be at the top under includes
new pMoneyDeath[MAX_PLAYERS];
new LastMoney;
new death_pickup;
forward messagepickup();

public OnPlayerDeath(playerid, killerid, reason)
{
    GetPlayerCash(playerid, pMoneyDeath[playerid]);
    // Declare 3 float variables to store the X, Y and Z coordinates in
    new Float:x, Float:y, Float:z;
 
    // Use GetPlayerPos, passing the 3 float variables we just created
    GetPlayerPos(playerid, x, y, z);
 
    // Create a cash pickup at the player's position
    death_pickup = CreatePickup(1212, 4, x, y, z, -1); //Change the pickupid if you want
    SetTimer("messagepickup", 15000, false);
    LastMoney = pMoneyDeath[playerid];
    return 1;

}

public messagepickup()
{
    //some time later...
    DestroyPickup(death_pickup);
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == death_pickup)
    {
        GivePlayerMoney(playerid, LastMoney);
    }
    return 1;
}
This will give the players cash when the player picksup the pickup
Hey bro,
it gave me these Errors:
PHP код:
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(2666) : error 017undefined symbol "GetPlayerCash"
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(2666) : warning 215expression has no effect
C
:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(2666) : error 001expected token";"but found "]"
C:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(2666) : error 029invalid expressionassumed zero
C
:\Users\Charalambos\Desktop\bible\gamemodes\WarZ.pwn(2666) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors




Re: how to make DeathPickup - hamzajaved780 - 01.06.2015

Now it should work

Код:
// This should be at the top under includes
new pMoneyDeath[MAX_PLAYERS];
new LastMoney;
new death_pickup;
forward messagepickup();

public OnPlayerDeath(playerid, killerid, reason)
{
    GetPlayerMoney(playerid, pMoneyDeath[playerid]);
    // Declare 3 float variables to store the X, Y and Z coordinates in
    new Float:x, Float:y, Float:z;
 
    // Use GetPlayerPos, passing the 3 float variables we just created
    GetPlayerPos(playerid, x, y, z);
 
    // Create a cash pickup at the player's position
    death_pickup = CreatePickup(1212, 4, x, y, z, -1); //Change the pickupid if you want
    SetTimer("messagepickup", 15000, false);
    LastMoney = pMoneyDeath[playerid];
    return 1;

}

public messagepickup()
{
    //some time later...
    DestroyPickup(death_pickup);
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == death_pickup)
    {
        GivePlayerMoney(playerid, LastMoney);
    }
    return 1;
}



AW: how to make DeathPickup - Kaliber - 01.06.2015

This could bug, if more than 1 guy dies

Write it like this:

PHP код:
new Death_Pick[3][MAX_PLAYERS];
public 
OnPlayerDeath(playerid,killerid,reason)
{
    if(
GetPlayerMoney(playerid) > 0)
    {
        
Death_Pick[0][playerid] = GetPlayerMoney(playerid);
        
GivePlayerMoney(playerid,-Death_Pick[0][playerid]);
        new 
Float:xFloat:yFloat:z;
        
GetPlayerPos(playeridxyz);
        
Death_Pick[1][playerid] = CreatePickup(12122xyzGetPlayerVirtualWorld(playerid));
        
Death_Pick[2][playerid] = SetTimerEx("@dP",1000*15,0,"i",playerid);
    }
    else 
SendClientMessage(playerid,-1,"* Lucker, you have no money to loose!");
    return 
1;
}
@
dP(i);@dP(i) return DestroyPickup(Death_Pick[1][i]),Death_Pick[1][i]=0;
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    for(new 
ii<MAX_PLAYERSi++) {
        if(
Death_Pick[1][i] != pickupid) continue;
        
GivePlayerMoney(playerid,Death_Pick[0][i]),
        
DestroyPickup(Death_Pick[1][i]),
        
KillTimer(Death_Pick[2][i]),
        
Death_Pick[1][i]=0;
        break;
    }
    return 
1;

Greekz


Re: AW: how to make DeathPickup - FrankLucretti - 01.06.2015

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
This could bug, if more than 1 guy dies

Write it like this:

PHP код:
new Death_Pick[3][MAX_PLAYERS];
public 
OnPlayerDeath(playerid,killerid,reason)
{
    if(
GetPlayerMoney(playerid) > 0)
    {
        
Death_Pick[0][playerid] = GetPlayerMoney(playerid);
        
GivePlayerMoney(playerid,-Death_Pick[0][playerid]);
        new 
Float:xFloat:yFloat:z;
        
GetPlayerPos(playeridxyz);
        
Death_Pick[1][playerid] = CreatePickup(12122xyzGetPlayerVirtualWorld(playerid));
        
Death_Pick[2][playerid] = SetTimerEx("@dP",1000*15,0,"i",playerid);
    }
    else 
SendClientMessage(playerid,-1,"* Lucker, you have no money to loose!");
    return 
1;
}
@
dP(i);@dP(i) return DestroyPickup(Death_Pick[1][i]),Death_Pick[1][i]=0;
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    for(new 
ii<MAX_PLAYERSi++) {
        if(
Death_Pick[1][i] != pickupid) continue;
        
GivePlayerMoney(playerid,Death_Pick[0][i]),
        
DestroyPickup(Death_Pick[1][i]),
        
KillTimer(Death_Pick[2][i]),
        
Death_Pick[1][i]=0;
        break;
    }
    return 
1;

Greekz
Eyxaristw file mou,
thanks bro.
I will test it


Re: how to make DeathPickup - FrankLucretti - 01.06.2015

This function

PHP код:
@dP(i);@dP(i) return DestroyPickup(Death_Pick[1][i]),Death_Pick[1][i]=0
Gives error :/


AW: Re: how to make DeathPickup - Kaliber - 01.06.2015

Quote:
Originally Posted by FrankLucretti
Посмотреть сообщение
Gives error :/
What error?!

You must write it outside any code-block...