SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 21/08/2019, 05:28 PM   #1
Spawe
Big Clucker
 
Spawe's Avatar
 
Join Date: Sep 2018
Posts: 156
Reputation: 3
Default problem [debug]

How do I solve the image problem




ONPLAYERDEATH PUBLIC

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
        SendDeathMessage(killerid, playerid, reason);
	else
    	SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
    	
    new Asesino[MAX_PLAYER_NAME];
    PlayerInfo[killerid][cScore]++; 
    SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
    E4_GivePlayerMoney(killerid,100);
    PlayerInfo[killerid][cKills]++;
    PlayerInfo[playerid][cDeaths]++;
    BuscadoPorServer[killerid]++;
    BuscadoPorServer[playerid] = 0;
    SetPlayerVip(killerid);
    ActualizarNivel(killerid);
    GetPlayerName(killerid,Asesino,100);
    E4_TogglePlayerSpectating(playerid, 1);
    PlayerSpectatePlayer(playerid, killerid);
    Info[playerid][pCurHealth] = 100.0;
    Info[playerid][pCurArmour] = 0.0;

    
   	if(killerid != INVALID_PLAYER_ID)
	{
		if(PlayerInfo[killerid][DioHS]==1)
		{
		    PlayerInfo[killerid][DioHS]=0;
			PlayerInfo[killerid][cScore]++;
			GameTextForPlayer(killerid,"_~n~_~n~_~n~_~n~_~n~_~n~_~n~~g~->~r~ HeadShoot ~g~<-", 4000, 6);
		} else
			GameTextForPlayer(killerid,KSMensajes[random(sizeof(KSMensajes))], 4000, 6);
	}
	
	if(PlayerDuelo[playerid][Estaenduelo]==1 && PlayerDuelo[killerid][Estaenduelo]==1)
	{
 		if(PlayerDuelo[playerid][Contrincante]==killerid && PlayerDuelo[killerid][Contrincante]==playerid)
   		{
			DueloInfo[PlayerDuelo[killerid][ArenaID]][Desocupada] =1;
			DueloInfo[PlayerDuelo[killerid][ArenaID]][Desafiador]=-1;
			DueloInfo[PlayerDuelo[killerid][ArenaID]][Desafiado] =-1;
			DueloInfo[PlayerDuelo[killerid][ArenaID]][Iniciar]  =  0;
			PlayerDuelo[playerid][Estaenduelo]=0;
			PlayerDuelo[playerid][Contrincante]=-1;
			PlayerDuelo[killerid][Estaenduelo]=0;
			PlayerDuelo[killerid][Contrincante]=-1;
			PlayerDuelo[playerid][ArenaID]=-1;
			PlayerDuelo[killerid][ArenaID]=-1;
			new string[97];
			format(string,sizeof(string),"** %s (%d) le ha ganado el duelo a %s (%d)",PlayerName2(killerid),killerid,PlayerName2(playerid),playerid);
			SendClientMessageToAll(COLOR_DUELO,string);
			SpawnPlayer(killerid);
   		}
	}
    
	if(MontoTotal[playerid] > 0)
	{
 		new str[128];
   		format(str,sizeof(str),"INFO <X>  %s (%d) a matado a %s (%d) y a obtenido la recompensa",PlayerName2(killerid),killerid,PlayerName2(playerid),playerid);
	    SendClientMessageToAll(COLOR_NARANJA,str);
		E4_GivePlayerMoney(killerid,MontoTotal[playerid]);
		MontoTotal[playerid] = 0;
	}
	
	switch(PlayerInfo[killerid][cNivel])
	{
		case 0: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+10.0;
		case 1: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+9.5;
		case 2: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+9.0;
		case 3: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+8.5;
		case 4: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+8.0;
		case 5: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+7.5;
		case 6: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+7.0;
		case 7: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+6.5;
		case 8: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+6.0;
		case 9: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+5.5;
		case 10: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+5.0;
		case 11: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+4.5;
		case 12: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+4.0;
		case 13: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+3.5;
		case 14: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+3.0;
		case 15: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+2.5;
		case 16: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+2.0;
		case 17: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+1.8;
		case 18: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+1.6;
		case 19: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+1.4;
		case 20: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+1.2;
		case 21: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+1.0;
		case 22: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.9;
		case 23: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.8;
		case 24: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.7;
		case 25: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.6;
		case 26: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.6;
		case 27: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.5;
		case 28: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.4;
		case 29: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.3;
		case 30: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.2;
		case 31: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.1;
		case 32: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.09;
		case 33: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.08;
		case 34: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.07;
		case 35: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.06;
		case 36: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.05;
		case 37: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.04;
		case 38: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.03;
		case 39: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.02;
		case 40: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.01;
		case 41: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.009;
		case 42: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.008;
		case 43: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.007;
		case 44: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.006;
		case 45: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.005;
		case 46: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.004;
		case 47: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.003;
		case 48: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.002;
		case 49: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.001;
		case 50: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0009;
		case 51: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0008;
		case 52: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0007;
		case 53: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0006;
		case 54: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0005;
		case 55: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0004;
		case 56: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0003;
		case 57: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0002;
		case 58: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.0001;
		case 59: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00009;
		case 60: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00008;
		case 61: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00007;
		case 62: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00006;
		case 63: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00005;
		case 64: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00004;
		case 65: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00003;
		case 66: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00002;
		case 67: PlayerInfo[killerid][Experiencia]=PlayerInfo[killerid][Experiencia]+0.00001;
	}
	
	if(reason == 49 || reason == 50)
		Encarcelar(killerid,"[Carkill/Helikill]",-1);

	switch(BuscadoPorServer[killerid])
	{
 		case 10:
   		{
			MontoTotal[killerid] = MontoTotal[killerid] + 1000;
			new str[128];
			format(str,sizeof(str),"INFO <X>  El servidor ofrece una recompensa de $1,000 por la cabeza de %s (%d), total $%d",PlayerName2(killerid),killerid,MontoTotal[killerid]);
			SendClientMessageToAll(COLOR_NARANJA,str);
		}
  		case 20:
  		{
			MontoTotal[killerid] = MontoTotal[killerid] + 2500;
			new str[128];
			format(str,sizeof(str),"INFO <X>  El servidor ofrece una recompensa de $2,500 por la cabeza de %s (%d), total $%d",PlayerName2(killerid),killerid,MontoTotal[killerid]);
			SendClientMessageToAll(COLOR_NARANJA,str);
		}
  		case 30:
    	{
			MontoTotal[killerid] = MontoTotal[killerid] + 4000;
			new str[128];
			format(str,sizeof(str),"INFO <X>  El servidor ofrece una recompensa de $4,000 por la cabeza de %s (%d), total $%d",PlayerName2(killerid),killerid,MontoTotal[killerid]);
			SendClientMessageToAll(COLOR_NARANJA,str);
		}
  		case 40:
  		{
			MontoTotal[killerid] = MontoTotal[killerid] + 5500;
			new str[128];
			format(str,sizeof(str),"INFO <X>  El servidor ofrece una recompensa de $5,500 por la cabeza de %s (%d), total $%d",PlayerName2(killerid),killerid,MontoTotal[killerid]);
			SendClientMessageToAll(COLOR_NARANJA,str);
		}
  		case 55:
  		{
			MontoTotal[killerid] = MontoTotal[killerid] + 7000;
			new str[128];
			format(str,sizeof(str),"INFO <X>  El servidor ofrece una recompensa de $7,000 por la cabeza de %s (%d), total $%d",PlayerName2(killerid),killerid,MontoTotal[killerid]);
			SendClientMessageToAll(COLOR_NARANJA,str);
		}
	}
	SetPlayerVip(playerid);
	return 1;
}
__________________
New project in creation, follow us in fb to not miss anything
Spawe is offline   Reply With Quote
Old 21/08/2019, 05:33 PM   #2
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: problem [debug]

Before using killerid in arrays and functions, make sure the player is valid.

You do not have to check if player is valid for SendDeathMessage by the way.
Calisthenics is offline   Reply With Quote
Old 21/08/2019, 05:40 PM   #3
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 121
Reputation: 43
Default Re: problem [debug]

All of the [killerid] variable handling should be below

Quote:
if(killerid != INVALID_PLAYER_ID)
{
Markski is offline   Reply With Quote
Old 21/08/2019, 06:53 PM   #4
Spawe
Big Clucker
 
Spawe's Avatar
 
Join Date: Sep 2018
Posts: 156
Reputation: 3
Default Re: problem [debug]

I do not understand, what would be the solution
__________________
New project in creation, follow us in fb to not miss anything
Spawe is offline   Reply With Quote
Old 21/08/2019, 06:59 PM   #5
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 272
Reputation: 27
Default Re: problem [debug]

Everywhere where you use killerid, you have to check if it is valid (not 65535/INVALID_PLAYER_ID)
Plastikmensch is offline   Reply With Quote
Old 23/08/2019, 09:02 AM   #6
Spawe
Big Clucker
 
Spawe's Avatar
 
Join Date: Sep 2018
Posts: 156
Reputation: 3
Default Re: problem [debug]

specifically how I solve it, I have already confirmed several killerid but the problem continues
__________________
New project in creation, follow us in fb to not miss anything
Spawe is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
debug problem JuzDoiT Scripting Help 2 05/05/2017 06:56 AM
debug problem JuzDoiT Scripting Help 0 04/05/2017 10:17 AM
debug problem Jony_Cruze Scripting Help 28 14/11/2013 01:50 PM
[debug] Problem Regziol Scripting Help 0 15/07/2013 01:47 PM
debug problem sandisk125 Server Support 4 02/08/2009 11:24 PM


All times are GMT. The time now is 03:14 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.