Every time I die
#1

Money doubles when I die
I want it so that when a player dies, it randomly takes away a small amount of money.
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   GivePlayerMoney(playerid,-500-random(500));
}
this will take an small ammount from 500 to 1000 (random)
Reply
#3

It still causes the money to double along with the money that is supposed to be taken away

Ex: I have 5000
And its supposed to take 100 away
I die and now I have 10100
>_<
Reply
#4

Its caused because another script in your gamemode.
Is the money doubling on player spawn or on player death?
Reply
#5

Death
Reply
#6

Show us your OnPlayerDeath please.
Reply
#7

GameMode OnPlayerDeath

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{

    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(IsPlayerCop(playerid)) Iter_Remove(Cops, playerid);
    PlayerInfo[playerid][SessionKills] = 0;
    if(IsPlayerCop(playerid))
    {
        for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(WantedInfo[i][playerid][WantedZone] != 0)
            {
                GangZoneDestroy(WantedInfo[i][playerid][WantedZone]);
            }
        }
    }
    else if(PlayerInfo[playerid][CriminalLevel] > 1)
    {
        for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(WantedInfo[playerid][i][WantedZone] != 0)
            {
                GangZoneDestroy(WantedInfo[playerid][i][WantedZone]);
                TextDrawHideForPlayer(playerid, PlayerInfo[playerid][Textdraw0]);
            }
        }
    }
    new bool:send=true;
    if(killerid != INVALID_PLAYER_ID)
    {
        if(IsPlayerCop(killerid))
        {
            if(PlayerInfo[playerid][CriminalLevel] >= 6)
            {
                GameTextForPlayer(killerid, "~b~You killed a wanted criminal~n~~r~+$5000", 3000, 3);
                GivePlayerMoneyEx(killerid, 5000);
            }
            if(PlayerInfo[playerid][CriminalLevel] <= 1)
            {
                GameTextForPlayer(killerid, "~r~Dont kill white or yellow players~n~-$2000", 3000, 3);
                GivePlayerMoneyEx(killerid, -2000);
                send=false;
            }
        }
        if(send)
        {
            PlayerInfo[killerid][SessionKills]++;
            if(PlayerInfo[killerid][SessionKills] > 2)
            {
                new string[128];
                format(string, 128, "~y~]~r~Killing Spree ~y~of ~r~%d Kills~y~]", PlayerInfo[killerid][SessionKills]);
                GameTextForPlayer(killerid, string, 2000, 3);
            }
        }
        PlayerInfo[killerid][Kills]++;
        if(!IsPlayerCop(killerid))
        {
            if(PlayerInfo[killerid][Job] == 1)
            {
                for(new h=0; h < MAX_PLAYERS; h++)
                {
                    if(Hits[h][0])
                    {
                        if(strfind(Hits[h],PlayerName(playerid),true) != -1)
                        {
                            new string[128];
                            format(string, 128, "CONTRACT: You killed %s, who had a contract placed on him for $%d.", PlayerName(playerid), PlayerInfo[playerid][HasHit]);
                            SendClientMessage(killerid, COLOR_GREEN, string);
                            SendClientMessage(playerid, COLOR_GREEN, "CONTRACT: You were killed for a hitman contract");
                            GivePlayerMoneyEx(killerid, PlayerInfo[playerid][HasHit]);
                            PlayerInfo[playerid][HasHit] = 0;
                            Hits[h]="9999";
                        }
                    }
                }
            }
            IncreaseWantedLevel(killerid, 4);
            SendClientMessage(killerid, COLOR_RED, "WANTED: You have commited first degree murder. Your wanted level has increased.");
        }
        TogglePlayerSpectating(playerid, 1);
        if(IsPlayerInAnyVehicle(killerid))
        {
            PlayerSpectateVehicle(playerid, GetPlayerVehicleID(killerid));
        }
        else
        {
            PlayerSpectatePlayer(playerid, killerid);
        }
        SetTimerEx("stopspec", 10000, 0, "u", playerid);
        new string[128];
        format(string, 128, "~r~Killed by %s~n~~w~Spawning in ~r~10~w~seconds", PlayerName(killerid));
        GameTextForPlayer(playerid, string, 3000, 3);
    }
    new playerweapons[13][2];
    for(new i=0; i < 13; i++)
    {
        GetPlayerWeaponData(playerid, i, playerweapons[i][0], playerweapons[i][1]);
        new Float:X=x+(random(3)-random(3));
        new Float:Y=y+(random(3)-random(3));
        new pickup;
        switch(playerweapons[i][0])
        {
            case 22: { pickup=CreatePickup(346,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=22; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//. //colt
            case 23: { pickup=CreatePickup(347,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=23; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//.
            case 24: { pickup=CreatePickup(348,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=24; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//.
            case 25: { pickup=CreatePickup(349,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=25; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//.
            case 30: { pickup=CreatePickup(355,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=30; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//.
            case 27: { pickup=CreatePickup(351,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=27; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//.
            case 31: { pickup=CreatePickup(356,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=31; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//
            case 34: { pickup=CreatePickup(358,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=34; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//
            case 29: { pickup=CreatePickup(353,1,X,Y,z); Iter_Add(WeapPickups,pickup); weapon[pickup]=29; weapontime[pickup]=10; }//, 0, 0, -1, 20.0);//.
            //346,347,348,349,351,353,355,356,358
        }
    }
    TextDrawHideForPlayer(playerid,txtTimeDisp);
    SendDeathMessage(killerid, playerid, reason);
    PlayerInfo[playerid][Deaths]++;
    PlayerInfo[playerid][Spawned] = false;
    PlayerInfo[playerid][CriminalLevel] = 0;
    SetPlayerWantedLevel(playerid, 0);
    if(!IsPlayerCop(playerid)) SetPlayerColor(playerid, COLOR_WHITE);
    for(new i=0; i < 14; i++)
    {
        PlayerCrimes[playerid][i] = 9999;
    }
    DataSaveForPlayer(playerid);
    return 1;
}

Filterscript-Register/Admin OnPlayerDeath
pawn Код:
public OnPlayerDeath(playerid, killerid)
{
    new file[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"/mRegistration/Users/%s.ini",name);
    if(fexist(file)){
    dini_Create(file);
    dini_IntSet(file,"Score", GetPlayerScore(playerid));
    dini_IntSet(file,"Money", GetPlayerMoney(playerid));
    GetPlayerPos(playerid,x,y,z);
    PlayerInfo[playerid][posx] = x;
    PlayerInfo[playerid][posy] = y;
    PlayerInfo[playerid][posz] = z;
    dini_FloatSet(file,"posx", PlayerInfo[playerid][posx]);
    dini_FloatSet(file,"posy", PlayerInfo[playerid][posy]);
    dini_FloatSet(file,"posz", PlayerInfo[playerid][posz]);
    PlayerInfo[playerid][Deaths] ++;
    PlayerInfo[killerid][Kills] ++;
    }
    return 1;
}
Reply
#8

use the tags [pawn] and not [code]
Reply
#9

Bump
Reply
#10

Show your OnPlayerSpawn plz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)