Needing a little help with 'OnPlayerDeath'
#1

So I'm fairly new to scripting, it's been about 2 or three months since I actually started learning things. I'm now working on a Team death match script for funzies.

My problem?

alright this is ma code


Код:
public OnPlayerDeath(playerid, killerid, reason)
{
        new st[256];
        new name[MAX_PLAYER_NAME];
        new Killername[MAX_PLAYER_NAME];
        new wlevel = PlayerInfo[killerid][pWantedLevel];
		new Float:x, Float:y, Float:z;
		for(new i=0;i<MAX_PLAYERS;i++)
        GetPlayerName(playerid,name,sizeof(name));
	    GetPlayerName(killerid,Killername,sizeof(Killername));


        SetPlayerWantedLevel(playerid,0);
        PlayerInfo[playerid][pDeaths] += 1;

	    PlayerInfo[killerid][pKills] += 1;
	    SetPlayerScore(killerid, PlayerInfo[killerid][pKills]);
	    GivePlayerCash(killerid, 2500);


        SendDeathMessage(killerid,playerid,reason);
        Delete3DTextLabel(Killer[playerid]);
        LooseWeapons(playerid);
        Kills[playerid] = 0;
        Kills[killerid]++;

    

        if(Kills[killerid] == 5)
        {
	      format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 5!",Killername);
	      GameTextForAll(st,5000,4);
	      PlayerInfo[killerid][pWantedLevel] = wlevel + 1;
	      GivePlayerCash(killerid, 5000);
	      
        }
        if(Kills[killerid] == 10)
        {
	      format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 10!!",Killername);
	      PlayerInfo[killerid][pWantedLevel] = wlevel + 1;
	      GameTextForAll(st,5000,4);
        }
        if(Kills[killerid] == 15)
        {
	      format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 15!!!",Killername);
	      PlayerInfo[killerid][pWantedLevel] = wlevel + 1;
	      GameTextForAll(st,5000,4);
        }
        if(Kills[killerid] == 20)
        {
	      format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 20!!!!",Killername);
	      GivePlayerCash(killerid, 15000);
	      PlayerInfo[killerid][pWantedLevel] = wlevel + 1;
	      GameTextForAll(st,5000,4);
        }
        if(Kills[killerid] == 25)
        {
	      format(st,sizeof(st),"~W~%s HAS A KILL STREAK OF 25!!!!!",Killername);
	      PlayerInfo[killerid][pWantedLevel] = wlevel + 1;
	      GameTextForAll(st,5000,4);
        }
        if(Kills[killerid] == 30)
        {
	      format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF 30!!!!!!",Killername[killerid]);
	      GameTextForAll(st,5000,4);
        }
        if(Kills[killerid] == 35)
        {
	      format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF 35!!!!!!",Killername[killerid]);
	      PlayerInfo[killerid][pWantedLevel] = wlevel + 1;
	      GameTextForAll(st,5000,4);
        }
        if(Kills[killerid] == 40)
        {
	      format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF 40!!!!!!",Killername[killerid]);
	      GameTextForAll(st,5000,4);
        }
        if(Kills[killerid] == 45)
        {
	      format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF 45!!!!!!",Killername[killerid]);
	      GivePlayerCash(killerid, 25000);
	      PlayerInfo[killerid][pWantedLevel] = wlevel + 1;
	      GameTextForAll(st,5000,4);
        }
        if(Kills[killerid] == 50)
        {
	      format(st,sizeof(st),"~G~%s HAS A KILL STREAK OF 50 EVERYONE KILL HIM/HER!!!!!!",Killername[killerid]);
	      GameTextForAll(st,5500,5);
	      Killer[playerid] = Create3DTextLabel("KILL THIS GUY",GetPlayerColor(playerid),0.0,0.0,0.0,NAMETAG_DRAW_DISTANCE,-1,0);
		  Attach3DTextLabelToPlayer(Killer[playerid],playerid,0.0,0.0,0.75);
	      GetPlayerPos(killerid,x,y,z);
		  SetPlayerPos(MAX_PLAYERS,x,y,z);
    	}
    	if(Kills[killerid]>= 50)
        {
	      format(st,sizeof(st),"~R~%s HAS A KILL STREAK OF %s",Killername, Kills[killerid]);
	      GameTextForAll(st,5000,4);
        }
    return 1;
}
What works is, it gives the player money. the death message shows, weapons do drop, stats and score is changed BUT the kill++ are not working (i think) because the kill streaks dont work
Reply
#2

Well look at it. You're adding 1 to this variable when they get a kill.

pawn Код:
PlayerInfo[killerid][pKills] += 1;
Yet you check for killstreaks with this variable.

pawn Код:
if(Kills[killerid] == 5)
Reply
#3

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
Well look at it. You're adding 1 to this variable when they get a kill.

pawn Код:
PlayerInfo[killerid][pKills] += 1;
Yet you check for killstreaks with this variable.

pawn Код:
if(Kills[killerid] == 5)
No,
PlayerInfo[killerid][pKills] += 1;
is for the stats of the account.

I'm using
Kills[killerid]++;
to add the variable
Reply
#4

I see. Why wouldn't you just use a single variable? And why do you have a loop at the beginning?
Reply
#5

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
I see. Why wouldn't you just use a single variable? And why do you have a loop at the beginning?
With the pkills when you login you can always check your /stats and will keep tally of all the kills you have gotten. The other variable is kill streak and is reset once you die. what loop?
Reply
#6

This at the top.

pawn Код:
for(new i=0;i<MAX_PLAYERS;i++)
Reply
#7

i have no idea. any chance that could stop the kill streaks from working?
Reply
#8

It couldn't help. Try this.

http://pastebin.com/YjWgTQGd
Reply
#9

Still doesn't work
Reply
#10

You have to handle the cases where the killer ID is invalid.

http://pastebin.com/uwLXZiGc
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)