Paintball bug
#1

Hello.

I have a problem at paintball system:
When the round ends it does not reset kills all, sometimes to me or my friend.. random... and
do not reset the weapons.
I tried to solve but I can not ..
CODE:
Код:
new  SQL =-1
// Local 
PaintballWinnerScore[3], PaintballWinner[3], PaintTime[3] = -1, etc.
//Global 
PaintType[MAX_PLAYERS], PKills[MAX_PLAYERS], PDeaths[MAX_PLAYERS], PaintTimer[MAX_MINIGAMES], PaintMap[MAX_MINIGAMES], MapVotes[MAX_MINIGAMES][MAX_MAPS], 
PaintVote[MAX_MINIGAMES], Voted[MAX_PLAYERS], PaintText[MAX_MINIGAMES],

// Text draw
PlayerText: PaintTD

pInfo:
pPaintKills[3],pPaintDeaths[3], 

if(PaintType[killerid] != 0 && PaintType[playerid] != 0) {
			if(PaintText[PaintType[playerid]-1] > 1) return 1;
			if(PaintTime[PaintType[playerid]-1] < 1) return 1;		
			
			for(new m; m < 2; m++) {
				if(PlayerInfo[killerid][pDailyMission][m] == 0) CheckMission(killerid, m);
			}	
			
			PlayerInfo[killerid][pPaintKills][PaintType[killerid]-1] ++;
			switch(PaintType[killerid]-1) {
				case 0: UpdateVar(killerid, "PaintKills1", PlayerInfo[killerid][pPaintKills][PaintType[killerid]-1]);
				case 1: UpdateVar(killerid, "PaintKills2", PlayerInfo[killerid][pPaintKills][PaintType[killerid]-1]);
				case 2: UpdateVar(killerid, "PaintKills3", PlayerInfo[killerid][pPaintKills][PaintType[killerid]-1]);				
			}	
			
			PlayerInfo[playerid][pPaintDeaths][PaintType[playerid]-1] ++;		
			switch(PaintType[playerid]-1) {
				case 0: UpdateVar(playerid, "PaintDeaths1", PlayerInfo[playerid][pPaintDeaths][PaintType[playerid]-1]);
				case 1: UpdateVar(playerid, "PaintDeaths2", PlayerInfo[playerid][pPaintDeaths][PaintType[playerid]-1]);
				case 2:	UpdateVar(playerid, "PaintDeaths3", PlayerInfo[playerid][pPaintDeaths][PaintType[playerid]-1]);			
			}	
			PKills[killerid] ++;
			PDeaths[playerid] ++;
			if(PaintType[killerid] == 3 && PaintType[playerid] == 3) {
				if(GetPaintLevel(playerid) == 8) {
					foreach(Player,i) {
					    if(IsPlayerConnected(i) && IsPlayerLogged[i] == 1) {
							if(PaintType[i] == PaintType[killerid]) {
								new pp = PaintType[killerid]-1;
								for(new m = 0; m < 5; m++) SendDeathMessageToPlayer(i, 1001, 1001, 200);
								format(string, sizeof(string), "* %s a castigat runda deoarece a omorat pe %s cu cutitul.", GetName(killerid), GetName(playerid));
								SendPaintMessage(PaintType[i]-1, COLOR_YELLOW, string);
								PaintTime[pp] = 300;
								PKills[i] = 0, PDeaths[i] = 0;
								PaintballWinner[pp] = i;
								PaintballWinnerScore[pp] = 0;
								SpawnPlayer(i);
							}
						}
					}
				}
				else GiveSkillWeapon(killerid);
			}
			foreach(Player,i) if(PaintType[i] == PaintType[playerid] && PlayerInfo[i][pAdmin] == 0) SendDeathMessageToPlayer(i, killerid, playerid, reason);
		    if(PKills[killerid] > PaintballWinnerScore[PaintType[playerid]-1]) {
		        PaintballWinner[PaintType[playerid]-1]  = killerid;
	        	PaintballWinnerScore[PaintType[playerid]-1] = PKills[killerid];
	    	}
		}
Код:
else {
			if(PaintType[playerid] != 0) format(string, sizeof(string), "{5088BF}%s [%d kills]: {FFFFFF}%s", GetNameEx(playerid), PKills[playerid], text);
			else format(string, sizeof(string), "%s: {FFFFFF}%s", GetNameEx(playerid), text);
			if(PaintType[playerid] != 0) {
				SendPaintMessage(PaintType[playerid], -1, string);
				return 0;
			}
Код:
	case DIALOG_VOTE: {
			if(!response) return 1;
			MapVotes[PaintType[playerid]-1][listitem] ++;
			Voted[playerid] = 1;
			format(string, sizeof(string), "%s a votat pentru mapa %s.", GetName(playerid), MapName2(listitem));
			SendPaintMessage(PaintType[playerid], COLOR_CLIENT, string);
		}
Код:
case DIALOG_MODE: {
			if(!response) return 1;
			PaintType[playerid] = listitem+1;
			PKills[playerid] = 0, PDeaths[playerid] = 0;
			format(string, sizeof(string), "%s a intrat in arena de paintball.", GetName(playerid));
			SendPaintMessage(listitem+1, COLOR_YELLOW, string);
			PlayerTextDrawHide(playerid, PaintTD);
			ResetPlayerWeapons(playerid);
			PaintSpawn(playerid);
			if(PlayersOnPaint(listitem) == 2) {
				PaintTime[listitem] = -1;
				PaintText[listitem] = 60;
			    SendPaintMessage(listitem+1, COLOR_YELLOW, "Runda va incepe peste un minut. Pentru a vota o mapa, folositi comanda /votemap.");
				PaintVote[listitem] = 1;
				if(PaintTimer[listitem] != 0) KillTimer(PaintTimer[listitem]), PaintTimer[listitem] = 0;
				PaintTimer[listitem] = SetTimerEx("CalculateVote", 60000, 0, "i", listitem);
			}
			else if(PlayersOnPaint(listitem) < 2) SendClientMessage(playerid, COLOR_YELLOW, "Pentru a incepe runda, mai este nevoie de inca un jucator.");
		}
Код:
function CheckPaintball() {
	foreach(Player, i) {
		if(IsPlayerConnected(i) && IsPlayerLogged[i] == 1 && GetPlayerScore(i) != 0) {
			if(PlayersOnPaint(0) < 2 && PaintTime[0] != -1) {
				PaintTime[0] = -1;
				if(PaintType[i] == 1) {
					ResetPlayerWeapons(i);
					SendClientMessage(i, COLOR_YELLOW, "Runda a fost intrerupta deoarece ai ramas singur.");
					PlayerTextDrawHide(i, PaintTD);
					PKills[i] = 0, PDeaths[i] = 0;
					for(new m = 0; m < 5; m++) SendDeathMessageToPlayer(i, 1001, 1001, 200);
				}
			}
			if(PlayersOnPaint(1) < 2 && PaintTime[1] != -1) {
				PaintTime[1] = -1;
				if(PaintType[i] == 2) {
					ResetPlayerWeapons(i);
					SendClientMessage(i, COLOR_YELLOW, "Runda a fost intrerupta deoarece ai ramas singur.");
					PlayerTextDrawHide(i, PaintTD);
					PKills[i] = 0, PDeaths[i] = 0;
					for(new m = 0; m < 5; m++) SendDeathMessageToPlayer(i, 1001, 1001, 200);
				}
			}
			if(PlayersOnPaint(2) < 2 && PaintTime[2] != -1) {
				PaintTime[2] = -1;
				if(PaintType[i] == 3) {
					ResetPlayerWeapons(i);
					SendClientMessage(i, COLOR_YELLOW, "Runda a fost intrerupta deoarece ai ramas singur.");
					PlayerTextDrawHide(i, PaintTD);
					PKills[i] = 0, PDeaths[i] = 0;
					for(new m = 0; m < 5; m++) SendDeathMessageToPlayer(i, 1001, 1001, 200);
				}
			}
		}
	}
	return 1;
}
Код:
stock PaintRank(playerid, paintid) {
	new kills = PlayerInfo[playerid][pPaintKills][paintid] -  PlayerInfo[playerid][pPaintDeaths][paintid];
	new rank[64];
	if(kills < 0) rank = "Foarte rau";
	if(kills >= 0 && kills < 25) rank = "Incepator";	
	if(kills >= 25 && kills < 100) rank = "Avansat";	
	if(kills >= 100) rank = "Profesionist";		
	return rank;
}
Код:
function GetPaintLevel(playerid) {
	new level;
	switch(PKills[playerid]-PDeaths[playerid]) {
	    case 0..2: level = 1;
	    case 3..5: level = 2;
	    case 6..8: level = 3;
	    case 9..11: level = 4;
	    case 12..14: level = 5;
	    case 15..17: level = 6;
	    case 18..20: level = 7;
	    case 21..24: level = 8;
	}
	return level;
}

function SendPaintMessage(paintid, color, text[]) {
	foreach(Player, i) {
	    if(IsPlayerConnected(i) && PaintType[i] == paintid) {
	        SCM(i, color, text);
	    }
	}
	return 1;
}

function PlayersOnPaint(paintid) {
	new x;
	foreach(Player, i) {
		switch(paintid) {
			case 0: if(PaintType[i] == 1) x++; // classic
			case 1: if(PaintType[i] == 2) x++; // armour
			case 2: if(PaintType[i] == 3) x++; // gungame
		}
	}
	return x;
}
Код:
function CalculateVote(paintid) {
	PaintTime[paintid] = 0;
	PaintTimer[paintid] = 0;
	if(PlayersOnPaint(paintid) < 2) {
		SendPaintMessage(paintid+1, COLOR_CLIENT, "Votarea a fost anulata deoarece este un singur player.");
		return 1;
	}
	new string[180], map;
	PaintVote[paintid] = 0;
	if(MapVotes[paintid][0] >= MapVotes[paintid][1] && MapVotes[paintid][0] >= MapVotes[paintid][2] && MapVotes[paintid][0] >= MapVotes[paintid][3] && MapVotes[paintid][0] >= MapVotes[paintid][4] && MapVotes[paintid][0] >= MapVotes[paintid][5]) map = 0;
	else if(MapVotes[paintid][1] >= MapVotes[paintid][0] && MapVotes[paintid][1] >= MapVotes[paintid][2] && MapVotes[paintid][1] >= MapVotes[paintid][3] && MapVotes[paintid][1] >= MapVotes[paintid][4] && MapVotes[paintid][1] >= MapVotes[paintid][5]) map = 1;
	else if(MapVotes[paintid][2] >= MapVotes[paintid][0] && MapVotes[paintid][2] >= MapVotes[paintid][1] && MapVotes[paintid][2] >= MapVotes[paintid][3] && MapVotes[paintid][2] >= MapVotes[paintid][4] && MapVotes[paintid][2] >= MapVotes[paintid][5]) map = 2;
	else if(MapVotes[paintid][3] >= MapVotes[paintid][0] && MapVotes[paintid][3] >= MapVotes[paintid][1] && MapVotes[paintid][3] >= MapVotes[paintid][2] && MapVotes[paintid][3] >= MapVotes[paintid][4] && MapVotes[paintid][3] >= MapVotes[paintid][5]) map = 3;
	else if(MapVotes[paintid][4] >= MapVotes[paintid][0] && MapVotes[paintid][4] >= MapVotes[paintid][1] && MapVotes[paintid][4] >= MapVotes[paintid][2] && MapVotes[paintid][4] >= MapVotes[paintid][3] && MapVotes[paintid][4] >= MapVotes[paintid][5]) map = 4;
	else if(MapVotes[paintid][5] >= MapVotes[paintid][0] && MapVotes[paintid][5] >= MapVotes[paintid][1] && MapVotes[paintid][5] >= MapVotes[paintid][2] && MapVotes[paintid][5] >= MapVotes[paintid][3] && MapVotes[paintid][5] >= MapVotes[paintid][4]) map = 5;

	format(string, sizeof(string), "Votarea s-a terminat. Mapa %s a castigat cu %d voturi.", MapName2(map), MapVotes[paintid][map]);
	PaintMap[paintid] = map;
	if(paintid == 2) PaintTime[paintid] = 600;
	else PaintTime[paintid] = 300;
	SendPaintMessage(paintid+1, COLOR_CLIENT, string);
	MapVotes[paintid][0] = 0; MapVotes[paintid][1] = 0; MapVotes[paintid][2] = 0; MapVotes[paintid][3] = 0; MapVotes[paintid][4] = 0; MapVotes[paintid][5] = 0;
	foreach(Player, i) {
		if(IsPlayerConnected(i))  {
			if(PaintType[i] == paintid+1) Voted[i] = 0, SpawnPlayer(i);
		}
	}
	return 1;
}

stock MapName(paint) {
	new string[180];
	switch(PaintMap[paint]) {
		case 0: string = "rc_arena";
		case 1: string = "farm";
		case 2: string = "island";
		case 3: string = "desert";
		case 4: string = "beach";
		case 5: string = "forest";		
	}
	return string;
}

stock MapName2(paint) {
	new string[180];
	switch(paint) {
		case 0: string = "rc_arena";
		case 1: string = "farm";
		case 2: string = "island";
		case 3: string = "desert";
		case 4: string = "beach";
		case 5: string = "forest";
	}
	return string;
}
Код:
// Paintball arena
	if(painttime > 0) painttime--;
	if(PaintText[0] != 0) {
		PaintText[0] --;
		if(PaintText[0] == 0) format(string, 256, "~w~Runda a inceput~n~Succes tuturor!");
		else format(string, 256, "~w~Runda incepe in ~n~~b~%d secunde", PaintText[0]);
		GameTextForPaint(string, 0);
	}
	if(PaintText[1] != 0) {
		PaintText[1] --;
		if(PaintText[1] == 0) format(string, 256, "~w~Runda a inceput~n~Succes tuturor!");
		else  format(string, 256, "~w~Runda incepe in ~n~~b~%d secunde", PaintText[1]);
		GameTextForPaint(string, 1);
	}
	if(PaintText[2] != 0) {
		PaintText[2] --;
		if(PaintText[2] == 0) format(string, 256, "~w~Runda a inceput~n~Succes tuturor!");
		else  format(string, 256, "~w~Runda incepe in ~n~~b~%d secunde", PaintText[2]);
		GameTextForPaint(string, 2);
	}
	if(PlayersOnPaint(0) >= 2 && PaintTime[0] > 0) {
		PaintTime[0] --;
		if(PaintTime[0] == 0) {
			SendPaintMessage(1, COLOR_YELLOW, "Runda va incepe peste un minut. Pentru a vota o mapa, folositi comanda /votemap.");
			PaintVote[0] = 1;
			if(PaintTimer[0] != 0) KillTimer(PaintTimer[0]), PaintTimer[0] = 0;
			PaintTimer[0] = SetTimerEx("CalculateVote", 60000, 0, "i", 0);
		}
	}
	if(PlayersOnPaint(1) >= 2 && PaintTime[1] > 0) {
		PaintTime[1] --;
		if(PaintTime[1] == 0) {
			SendPaintMessage(1+1, COLOR_YELLOW, "Runda va incepe peste un minut. Pentru a vota o mapa, folositi comanda /votemap.");
			PaintVote[1] = 1;
			if(PaintTimer[1] != 0) KillTimer(PaintTimer[1]), PaintTimer[1] = 0;
			PaintTimer[1] = SetTimerEx("CalculateVote", 60000, 0, "i", 1);
		}
	}
	if(PlayersOnPaint(2) >= 2 && PaintTime[2] > 0) {
		PaintTime[2] --;
		if(PaintTime[2] == 0) {
			SendPaintMessage(2+1, COLOR_YELLOW, "Runda va incepe peste un minut. Pentru a vota o mapa, folositi comanda /votemap.");
			PaintVote[2] = 1;
			if(PaintTimer[2] != 0) KillTimer(PaintTimer[2]), PaintTimer[2] = 0;
			PaintTimer[2] = SetTimerEx("CalculateVote", 60000, 0, "i", 2);
		}
	}
Код:
if(PaintType[i] != 0 && PlayersOnPaint(PaintType[i]-1) >= 2) { // modificat aici in loc de 1 e 2
                new pp = PaintType[i]-1;
                if(pp < 2) {
                    format(string, sizeof(string), "Paintball time: %s~n~Current map: %s~n~Stats: %d kills, %d deaths.~n~Total score: %d~n~Best player: %s (kills: %d)~n~%d players in paintball.",
                    CalculeazaTimp2(PaintTime[pp]), MapName2(pp), PKills[i], PDeaths[i], PKills[i]-PDeaths[i], GetName(PaintballWinner[pp]), PKills[PaintballWinner[pp]], PlayersOnPaint(pp));
                }
                else {
                    new masadenume[32];
                    GetWeaponNameEx(GetPlayerWeapon(i), masadenume, sizeof(masadenume));
                    format(string, sizeof(string), "Paintball time: %s~n~Current map: %s~n~Stats: %d kills, %d deaths.~n~Total score: %d~n~Level %d, Weapon: %s~n~Best player: %s (kills: %d)~n~%d players in paintball.",
                    CalculeazaTimp2(PaintTime[pp]), MapName2(pp), PKills[i], PDeaths[i], PKills[i]-PDeaths[i], GetPaintLevel(i), masadenume, GetName(PaintballWinner[pp]), PKills[PaintballWinner[pp]], PlayersOnPaint(pp));
                }

                if(PaintTime[pp] == 0 && PaintballWinner[pp] != -1) {
                    for(new m = 0; m < 5; m++) SendDeathMessageToPlayer(i, 1001, 1001, 200);
                    format(string, sizeof(string), "Statistica ta in aceasta runda: %d ucideri si %d decese.", PKills[i], PDeaths[i]);
                    SCM(i, COLOR_YELLOW, string);
                    format(swinner, 256, "* %s a castigat runda cu %d ucideri.", GetName(PaintballWinner[pp]), PKills[PaintballWinner[pp]]);
                    PaintTime[pp] = 300;
                    PKills[i] = 0, PDeaths[i] = 0;
                    PKills[PaintballWinner[pp]] = 0; PDeaths[PaintballWinner[pp]] = 0;
                    SpawnPlayer(PaintballWinner[pp]);
                    PaintballWinner[pp] = i;
                    ResetWeapons(i);
                    PaintballWinnerScore[pp] = 0;
                    SendPaintMessage(PaintType[i], COLOR_YELLOW, swinner);
                    PaintballWinner[pp] = -1;
                    SpawnPlayer(i);
                }
				if(PaintTime[pp] != 0 && PaintText[pp] == 0) {
                    PlayerTextDrawSetString(i, PaintTD, string);
                    PlayerTextDrawShow(i, PaintTD);
                }
				else {
                    PlayerTextDrawHide(i, PaintTD);
                }
            }
			else PlayerTextDrawHide(i, PaintTD);

for(new i = 0; i < 3; i++) {
		if(PaintTime[i] == 0) {
			PaintTime[i] = -1; PaintText[i] = 20;
		}	
	}
Код:
	PlayerInfo[playerid][pPaintKills][0] = cache_get_field_content_int(0, "PaintKills1");
			PlayerInfo[playerid][pPaintKills][1] = cache_get_field_content_int(0, "PaintKills2");
			PlayerInfo[playerid][pPaintKills][2] = cache_get_field_content_int(0, "PaintKills3");
			PlayerInfo[playerid][pPaintDeaths][2] = cache_get_field_content_int(0, "PaintDeaths1");
			PlayerInfo[playerid][pPaintDeaths][2] = cache_get_field_content_int(0, "PaintDeaths2");
			PlayerInfo[playerid][pPaintDeaths][2] = cache_get_field_content_int(0, "PaintDeaths3");
Reply
#2

Reply
#3

Can you separate the code which says what will happen after player hits someone and your goal objective?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)