16.04.2014, 01:46
How to do a script if a player has $3000 on hand and he/she get killed his/her money will be dropped and can be get by another player by : pass by and he/she will get it.. i will give +rep
new cash_pickup;
if(GetPlayerMoney(playerid) > 3000) { // Player that died has more than 3000$ GivePlayerMoney(playerid, -3000); // Take 3000 from their money. new Float:x, Float:y, Float:z; // A place to store the place to create the pickup GetPlayerPos(playerid, x,y,z); // Get their x,y and z to create the pickup on cash_pickup = CreatePickup(1212, 5, x,y,z, -1); // Creates a pickup on the location where the player died. this pickup will disappear after some time
if(pickupid == cash_pickup) { GivePlayerMoney(playerid, 3000); // note: all players can pickup this pickup. Other players can take your cash reward. }
On top of your script:
Код:
new cash_pickup; Код:
if(GetPlayerMoney(playerid) > 3000) { // Player that died has more than 3000$ GivePlayerMoney(playerid, -3000); // Take 3000 from their money. new Float:x, Float:y, Float:z; // A place to store the place to create the pickup GetPlayerPos(playerid, x,y,z); // Get their x,y and z to create the pickup on cash_pickup = CreatePickup(1212, 5, x,y,z, -1); // Creates a pickup on the location where the player died. this pickup will disappear after some time Код:
if(pickupid == cash_pickup) { GivePlayerMoney(playerid, 3000); // note: all players can pickup this pickup. Other players can take your cash reward. } |
new cash_pickup;
new pickupcash;
new pmoney[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
// We put pmoney to zero because OnPlayerSpawn gets called after OnPlayerDeath
// This is just to prevent abuse but you may not even need this.
pmoney[playerid] = 0;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new Float:x, Float:y, Float:z;
if(GetPlayerMoney(playerid) > 3000)
{
pickupcash = pmoney[playerid];
pmoney[playerid] = GetPlayerMoney(playerid);
GetPlayerPos(playerid, x,y,z);
cash_pickup = CreatePickup(1212, 5, x,y,z, -1);
GivePlayerMoney(playerid, -pmoney[playerid]);
}
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == cash_pickup)
{
GivePlayerMoney(playerid, pickupcash);
}
return 1;
}