Help in OnPlayerDeath
#1

Hi guys, i've a problem with the callback OnPlayerDeath.
All the callback is as don't exist, also if is right; Help me please


Код:
new jjplayer[MAX_PLAYERS];
new bool:jjon = false;
new jasonid[MAX_PLAYERS] = 0;
new jason, playerjason, jjmorto[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{
	  if(playerid == jjplayer[playerid] && killerid == jasonid[killerid])
	  {
	  new namej[24], stringaj[128];
	  GetPlayerName(playerid, namej, sizeof(namej));
	  format(stringaj,128,"[EVENTO] Jason ha ucciso %s!", namej);
	  for(new i = 0; i < MAX_PLAYERS; i++)
	  {
	  if(jjplayer[i]) return SendClientMessage(i, giallo, stringaj);
	  if(jasonid[i]) return SendClientMessage(i, rosso, "*** Sete di saaaangue!"); }
	  jjmorto[playerid] = 1;
	  playerjason --;
	  }
	  if(killerid != jasonid[killerid] && playerid == jjplayer[playerid])
	  {
	  new namej[24], stringaj[128];
	  GetPlayerName(killerid, namej, sizeof(namej));
	  format(stringaj,128,"[EVENTO] %s и stato automaticamente kickato per aver killato un giocatore all'evento!");
	  SendClientMessageToAll(rosso, stringaj);
	  SetTimerEx("kick", 1000, false, "d", killerid); }
	  if(playerjason == 0) {
	  SendClientMessageToAll(rosso, "[EVENTO] Jason ha ucciso tutte le sue prede!");
	  SendClientMessageToAll(rosso, "Di conseguenza ha vinto 20 cookies e 30 EXP come premio!");
	  SendClientMessageToAll(giallo, "*** Evento Jason il Killer chiuso automaticamente!");
	  jjon = false;
	  for(new i = 0; i < MAX_PLAYERS; i++)
	  jjmorto[i] = 0, jjplayer[i] = 0, jasonid[i] = 0, jason = 0, playerjason = 0; }
          jjmorto[playerid] = 1;
	  jjplayer[playerid] = 0;
	  return 1;
}
Reply
#2

Run time errors can make your code stop and thus OnPlayerDeath won't work. Array index out of bounds is caused because you use killerid inside arrays without checking if the player is valid first (causing accessing element at index 65535).

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        if(playerid == jjplayer[playerid] && killerid == jasonid[killerid])
        {
            new namej[24], stringaj[128];
            GetPlayerName(playerid, namej, sizeof(namej));
            format(stringaj,128,"[EVENTO] Jason ha ucciso %s!", namej);
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(jjplayer[i]) return SendClientMessage(i, giallo, stringaj);
                if(jasonid[i]) return SendClientMessage(i, rosso, "*** Sete di saaaangue!");
            }
            jjmorto[playerid] = 1;
            playerjason --;
        }
        if(killerid != jasonid[killerid] && playerid == jjplayer[playerid])
        {
            new namej[24], stringaj[128];
            GetPlayerName(killerid, namej, sizeof(namej));
            format(stringaj,128,"[EVENTO] %s и stato automaticamente kickato per aver killato un giocatore all'evento!");
            SendClientMessageToAll(rosso, stringaj);
            SetTimerEx("kick", 1000, false, "d", killerid);
        }
    }
    if(playerjason == 0)
    {
        SendClientMessageToAll(rosso, "[EVENTO] Jason ha ucciso tutte le sue prede!");
        SendClientMessageToAll(rosso, "Di conseguenza ha vinto 20 cookies e 30 EXP come premio!");
        SendClientMessageToAll(giallo, "*** Evento Jason il Killer chiuso automaticamente!");
        jjon = false;
        for(new i = 0; i < MAX_PLAYERS; i++) jjmorto[i] = 0, jjplayer[i] = 0, jasonid[i] = 0, jason = 0, playerjason = 0;
    }
    jjmorto[playerid] = 1;
    jjplayer[playerid] = 0;
    return 1;
}
Reply
#3

Doesn't work

This is all the fs, sorry if you don't understand something, it's italian.

Ah ehm, doesn't work too OnPlayerTakeDamage

Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define giallo 0xFFFF00AA
#define grigio 0xAFAFAFAA
#define verde 0x33AA33AA
#define rosso 0xFF0000AA
#define blu 0x0000BBAA
#define azzurro 0x33CCFFAA
#define rossoscuro 0x660000AA
#define bianco 0xFFFFFFAA
#define biancoi 0xFFFFFF00
#define arancione 0xFF9900AA
#define viola 0x9E18E7FF
#define verdechiaro 0x8CED15
#define COLOR_IVORYS 0xFFFF82AA
#define nero 0x3C3C3CFF
#define limone 0x55FF00FF
#define marrone 0x7D0000FF
#define lime 0x32CD32AA
#define beige 0x9F9742FF

new jjplayer[MAX_PLAYERS];
new bool:jjon = false;
new jasonid[MAX_PLAYERS] = 0;
new jason, playerjason, jjmorto[MAX_PLAYERS];
//Timer
new Jasont1;
new Jasont2;
new Jasont3;
new Jasont4;


#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	for(new i = 0; i < MAX_PLAYERS, i++)
	{
	jasonid[i] = 0;
	jjplayer[i] = 0;
	jason = 0;
	playerjason = 0;
	jjon = false;
	jjmorto[i] = 0;
	}
	KillTimer(Jasont1);
	KillTimer(Jasont2);
    KillTimer(Jasont3);
    KillTimer(Jasont4);
	return 1;
}

public OnFilterScriptExit()
{
	for(new i = 0; i < MAX_PLAYERS, i++)
	{
	jasonid[i] = 0;
	jjplayer[i] = 0;
	jason = 0;
	playerjason = 0;
	jjon = false;
	jjmorto[i] = 0;
	}
	KillTimer(Jasont1);
    KillTimer(Jasont2);
    KillTimer(Jasont3);
    KillTimer(Jasont4);
	return 1;
}


#endif

//Timer

forward kick(playerid);
public kick(playerid)
{
	   kick(playerid);
}

forward antikill(playerid);
public antikill(playerid)
{
	   TogglePlayerControllable(playerid, 1);
	   GameTextForPlayer(playerid, "~g~scongelato!", 3000, 5);
}

forward jjsec(playerid);
public jjsec(playerid)
{
	for(new i = 0; i < MAX_PLAYERS; i ++)
	{
	  if(jjplayer[i] || jasonid[i])
	   {
	   SendClientMessage(jjplayer[playerid], rosso, "*** Sopravvivi!");
	   SendClientMessage(jasonid[playerid], rosso, "*** Squartali tutti, Jason!");
	   TogglePlayerControllable(i, 1);
	   GameTextForPlayer(i, "~g~go!", 3000, 5);
	   }
	}
}

forward inizioj(playerid);
public inizioj(playerid)
{
	for(new i = 0; i < MAX_PLAYERS; i ++)
    {
	  if(jjplayer[i] || jasonid[i])
	   {
	   SendClientMessage(jjplayer[i], giallo, "*** Tempo scaduto! L'evento inizierа tra 3 secondi.");
	   SendClientMessage(jasonid[i], giallo, "*** Tempo scaduto! L'evento inizierа tra 3 secondi.");
	   Jasont3 = SetTimer("jjsec", 3000, false);
	   TogglePlayerControllable(i, 0);
	   SetPlayerHealth(jasonid[i], 500);
	   }
	  if(jjplayer[i])
	   {
	   GivePlayerWeapon(i, 23, 15), GivePlayerWeapon(i, 5, 1);
	   SetPlayerHealth(i, 100);
	   }
	}
}

forward hidej(playerid);
public hidej(playerid)
{
	for(new i = 0; i < MAX_PLAYERS; i ++)
	{
	  if(jjplayer[i] || jasonid[i])
	   {
	   SendClientMessage(i, giallo, "*** Hai un minuto per nasconderti, dopodichи Jason verrа a cercarti!");
	   GameTextForPlayer(jjplayer[i], "~r~scappa!", 3000, 5);
	   Jasont2 = SetTimer("inizioj", 60000, false);
	   }
    }
}
//Comandi per gli admin

COMMAND:jjason(playerid,params[])
{
	if(jjon == true) return SendClientMessage(playerid, rosso, "*** L'evento и giа attivo!");
	jjon = true;
	new stringj[128], nomej[24];
	GetPlayerName(playerid, nomej, sizeof(nomej));
	format(stringj,128,"*** L'admin %s ha attivato l'evento Jason Il Killer! Per parteciparvi digita /joinj!", nomej);
	SendClientMessageToAll(verde, stringj);
	return 1;
}

COMMAND:jjasoff(playerid,params[])
{
	if(jjon == false) return SendClientMessage(playerid, rosso, "*** L'evento non и attivo!");
	jjon = false;
	new stringj[128], nomej[24];
	GetPlayerName(playerid, nomej, sizeof(nomej));
	format(stringj,128,"*** L'evento Jason Il Killer и stato disattivato dall'admin: %s!", nomej);
	SendClientMessageToAll(verde, stringj);
	for(new i = 0; i < MAX_PLAYERS; i++)
	jasonid[i] = 0, jjplayer[i] = 0, jjmorto[i] = 0, jason = 0, playerjason = 0;
	KillTimer(Jasont1), KillTimer(Jasont2), KillTimer(Jasont3), KillTimer(Jasont4);
	return 1;
}

COMMAND:jason(playerid,params[])
{
	new idj, stringj[128], nomej[24], nomeja[24];
	if(jjon == false) return SendClientMessage(playerid, rosso, "*** L'evento non и attivo!");
	if(sscanf(params, "u", idj)) return SendClientMessage(playerid, arancione, "Usa: /jason ID!");
	if(jason == 1) return SendClientMessage(playerid, rosso, "*** Puoi scegliere solo 1 jason!");
	if(idj == INVALID_PLAYER_ID) return SendClientMessage(playerid, rosso, "*** Questo utente non и connesso!");
	jjplayer[idj] = 0;
	jasonid[idj] = 1;
	jason ++;
	GetPlayerName(playerid, nomej, sizeof(nomej));
	GetPlayerName(idj, nomeja, sizeof(nomeja));
	format(stringj,128,"*** L'admin %s ha scelto come Jason dell'evento: %s!", nomej, nomeja);
	for(new i = 0; i < MAX_PLAYERS; i++)
	 {
		if(jjplayer[i])
		  {
		  SendClientMessage(i, verde, stringj);
		  }
	 }
	SendClientMessage(idj, verde, stringj);
	SetPlayerSkin(idj, 162);
    SetPlayerAttachedObject(idj, 0, 19036, 2, 0.107, 0.028, 0.0, 90, 90, 0);
    SetPlayerColor(idj, bianco);
    SetPlayerPos(idj, -463.6253,-188.2507,77.8555);
    SetPlayerFacingAngle(idj, 89.1170);
    TogglePlayerControllable(idj, 0);
    SetPlayerHealth(idj, 9999);
    GivePlayerWeapon(idj, 9, 1);
    return 1;
}

COMMAND:djason(playerid,params[])
{
	new idj, stringj[128], nomej[24], nomeja[24];
	if(jjon == false) return SendClientMessage(playerid, rosso, "*** L'evento non и attivo!");
	if(sscanf(params, "u", idj)) return SendClientMessage(playerid, arancione, "Usa: /djason ID!");
	if(jasonid[idj] == 0) return SendClientMessage(playerid, rosso, "*** Questo utente non и Jason!");
	if(idj == INVALID_PLAYER_ID) return SendClientMessage(playerid, rosso, "*** Questo utente non и connesso!");
	jjplayer[idj] = 1;
	jasonid[idj] = 0;
	GetPlayerName(playerid, nomej, sizeof(nomej));
	GetPlayerName(idj, nomeja, sizeof(nomeja));
	format(stringj,128,"*** L'admin %s ha tolto come Jason dell'evento: %s!", nomej, nomeja);
	for(new i = 0; i < MAX_PLAYERS; i++)
	 {
		if(jjplayer[i])
		  {
		  SendClientMessage(i, verde, stringj);
		  }
	 }
	SetPlayerSkin(idj, 10);
	SetPlayerColor(idj, nero);
	RemovePlayerAttachedObject(idj, 19036);
	jason --;
	TogglePlayerControllable(idj, 1);
	SetPlayerHealth(idj, 100);
	ResetPlayerWeapons(idj);
	return 1;
}

COMMAND:jjhide(playerid,params[])
{
	if(jjon == false) return SendClientMessage(playerid, rosso, "*** L'evento non и attivo!");
	if(jason == 0) return SendClientMessage(playerid, rosso, "*** Devi scegliere prima un Jason!");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if(jjplayer[i] || jasonid[i])
	{
	GameTextForPlayer(i, "~r~Pronti?", 3000, 5);
	}
	}
	Jasont1 = SetTimer("hidej", 3000, false);
	return 1;
}

//Comandi per i player

COMMAND:joinj(playerid,params[])
{
	if(jjplayer[playerid] == 1) return SendClientMessage(playerid, rosso, "*** Sei giа all'evento!");
	if(jjon == false) return SendClientMessage(playerid, rosso, "*** L'evento non и attivo!");
	if(jjmorto[playerid] == 1) return SendClientMessage(playerid, rosso, "*** Hai giа perso all'evento!");
	if(playerjason > 15) return SendClientMessage(playerid, rosso, "*** Posti finiti!");
	jjplayer[playerid] = 1;
	jasonid[playerid] = 0;
	playerjason ++;
	SetPlayerPos(playerid,-512.1125,-180.6595,77.2434);
	SetPlayerFacingAngle(playerid,171.0614);
	SetPlayerSkin(playerid, 10);
	SetPlayerColor(playerid, nero);
	ResetPlayerWeapons(playerid);
	SetPlayerVirtualWorld(playerid, 920);
	SetPlayerInterior(playerid, 0);
	return 1;
}

COMMAND:escij(playerid,params[])
{
	if(jjplayer[playerid] == 0) return SendClientMessage(playerid, rosso, "*** Non sei all'evento!");
	if(jjon == false) return SendClientMessage(playerid, rosso, "*** L'evento non и attivo!");
	if(jasonid[playerid] == 1) return SendClientMessage(playerid, rosso, "*** Non puoi uscire dall'evento perchи sei Jason! Fatti desettare da un admin.");
	jjplayer[playerid] = 0;
	new nomej[24], stringaj[128];
	GetPlayerName(playerid, nomej, sizeof(nomej));
	format(stringaj,128,"*** %s и uscito dall'evento Jason il Killer! (/escij)", nomej);
	SendClientMessageToAll(giallo, stringaj);
	SpawnPlayer(playerid);
	jjmorto[playerid] = 1;
	playerjason --;
	return 1;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////

public OnPlayerConnect(playerid)
{
    jasonid[playerid] = 0;
	jjplayer[playerid] = 0;
	jjmorto[playerid] = 0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    jasonid[playerid] = 0;
	jjplayer[playerid] = 0;
	jjmorto[playerid] = 0;
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        if(playerid == jjplayer[playerid] && killerid == jasonid[killerid])
        {
            new namej[24], stringaj[128];
            GetPlayerName(playerid, namej, sizeof(namej));
            format(stringaj,128,"[EVENTO] Jason ha ucciso %s!", namej);
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(jjplayer[i]) return SendClientMessage(i, giallo, stringaj);
                if(jasonid[i]) return SendClientMessage(i, rosso, "*** Sete di saaaangue!");
            }
            jjmorto[playerid] = 1;
            playerjason --;
        }
        if(killerid != jasonid[killerid] && playerid == jjplayer[playerid])
        {
            new namej[24], stringaj[128];
            GetPlayerName(killerid, namej, sizeof(namej));
            format(stringaj,128,"[EVENTO] %s и stato automaticamente kickato per aver killato un giocatore all'evento!");
            SendClientMessageToAll(rosso, stringaj);
            SetTimerEx("kick", 1000, false, "d", killerid);
        }
    }
    if(playerjason == 0)
    {
        SendClientMessageToAll(rosso, "[EVENTO] Jason ha ucciso tutte le sue prede!");
        SendClientMessageToAll(rosso, "Di conseguenza ha vinto 20 cookies e 30 EXP come premio!");
        SendClientMessageToAll(giallo, "*** Evento Jason il Killer chiuso automaticamente!");
        jjon = false;
        for(new i = 0; i < MAX_PLAYERS; i++) jjmorto[i] = 0, jjplayer[i] = 0, jasonid[i] = 0, jason = 0, playerjason = 0;
    }
    jjmorto[playerid] = 1;
    jjplayer[playerid] = 0;
    return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
	if(playerid == jjplayer[playerid] && issuerid == jjplayer[playerid])
	{
	SendClientMessage(issuerid, rosso, "*** Non attaccare i tuoi amici o verrai kickato!");
	Jasont4 = SetTimerEx("antikill", 3000, false, "d", issuerid);
	GameTextForPlayer(issuerid, "~r~No kill!", 5000, 5);
	SetPlayerHealth(playerid, 100);
	TogglePlayerControllable(issuerid, 0);
	}
    return 1;
}
Reply
#4

upppp
Reply
#5

up!!
Reply
#6

re up!
Reply
#7

up <.<
Reply
#8

help
Reply
#9

00000
Reply
#10

HELP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)