Killlog problems
#1

Hello I have some issues with kill log
Код:
    new msg[128], killerName[MAX_PLAYER_NAME], reasonMsg[32], playerName[MAX_PLAYER_NAME];
    GetPlayerName(killerid, killerName, sizeof(killerName));
    GetPlayerName(playerid, playerName, sizeof(playerName));

	if (killerid != INVALID_PLAYER_ID)
    {
        switch (reason)
        {
            case 0: reasonMsg = "Unarmed";
            case 1: reasonMsg = "Brass Knuckles";
            case 2: reasonMsg = "Golf Club";
            case 3: reasonMsg = "Night Stick";
            case 4: reasonMsg = "Knife";
            case 5: reasonMsg = "Baseball Bat";
            case 6: reasonMsg = "Shovel";
            case 7: reasonMsg = "Pool Cue";
            case 8: reasonMsg = "Katana";
            case 9: reasonMsg = "Chainsaw";
            case 10: reasonMsg = "Dildo";
            case 11: reasonMsg = "Dildo";
            case 12: reasonMsg = "Vibrator";
            case 13: reasonMsg = "Vibrator";
            case 14: reasonMsg = "Flowers";
            case 15: reasonMsg = "Cane";
            case 22: reasonMsg = "Pistol";
            case 23: reasonMsg = "Silenced Pistol";
            case 24: reasonMsg = "Desert Eagle";
            case 25: reasonMsg = "Shotgun";
            case 26: reasonMsg = "Sawn-off Shotgun";
            case 27: reasonMsg = "Combat Shotgun";
            case 28: reasonMsg = "MAC-10";
            case 29: reasonMsg = "MP5";
            case 30: reasonMsg = "AK-47";
            case 31: reasonMsg = "M4";
            case 32: reasonMsg = "TEC-9";
            case 33: reasonMsg = "Country Rifle";
            case 34: reasonMsg = "Sniper Rifle";
            case 37: reasonMsg = "Fire";
            case 38: reasonMsg = "Minigun";
            case 41: reasonMsg = "Spray Can";
            case 42: reasonMsg = "Fire Extinguisher";
            case 49: reasonMsg = "Vehicle Collision";
            case 50: reasonMsg = "Vehicle Collision";
            case 51: reasonMsg = "Explosion";
            default: reasonMsg = "Unknown";
        }
        	format(msg, sizeof(msg), "Player %s[%d] has killed %s[%i]. (%s)", killerName, killerid, playerName, playerid, reasonMsg);
    	}
    	else
    	{
        	switch (reason)
        	{
            	case 53: format(msg, sizeof(msg), "Player %s[%d] died. (Drowned)", playerName,playerid);
            	case 54: format(msg, sizeof(msg), "Player %s[%d] died. (Collision)", playerName,playerid);
            	default: format(msg, sizeof(msg), "Player %s[%d] died.", playerName,playerid);
    	        SendMessageToAllAdmins(msg, -1);
			}
        }
    }
When SendMessageToAllAdmins(msg, -1) is after else the compiler crashes but when its before the else like this
Код:
    new msg[128], killerName[MAX_PLAYER_NAME], reasonMsg[32], playerName[MAX_PLAYER_NAME];
    GetPlayerName(killerid, killerName, sizeof(killerName));
    GetPlayerName(playerid, playerName, sizeof(playerName));

	if (killerid != INVALID_PLAYER_ID)
    {
        switch (reason)
        {
            case 0: reasonMsg = "Unarmed";
            case 1: reasonMsg = "Brass Knuckles";
            case 2: reasonMsg = "Golf Club";
            case 3: reasonMsg = "Night Stick";
            case 4: reasonMsg = "Knife";
            case 5: reasonMsg = "Baseball Bat";
            case 6: reasonMsg = "Shovel";
            case 7: reasonMsg = "Pool Cue";
            case 8: reasonMsg = "Katana";
            case 9: reasonMsg = "Chainsaw";
            case 10: reasonMsg = "Dildo";
            case 11: reasonMsg = "Dildo";
            case 12: reasonMsg = "Vibrator";
            case 13: reasonMsg = "Vibrator";
            case 14: reasonMsg = "Flowers";
            case 15: reasonMsg = "Cane";
            case 22: reasonMsg = "Pistol";
            case 23: reasonMsg = "Silenced Pistol";
            case 24: reasonMsg = "Desert Eagle";
            case 25: reasonMsg = "Shotgun";
            case 26: reasonMsg = "Sawn-off Shotgun";
            case 27: reasonMsg = "Combat Shotgun";
            case 28: reasonMsg = "MAC-10";
            case 29: reasonMsg = "MP5";
            case 30: reasonMsg = "AK-47";
            case 31: reasonMsg = "M4";
            case 32: reasonMsg = "TEC-9";
            case 33: reasonMsg = "Country Rifle";
            case 34: reasonMsg = "Sniper Rifle";
            case 37: reasonMsg = "Fire";
            case 38: reasonMsg = "Minigun";
            case 41: reasonMsg = "Spray Can";
            case 42: reasonMsg = "Fire Extinguisher";
            case 49: reasonMsg = "Vehicle Collision";
            case 50: reasonMsg = "Vehicle Collision";
            case 51: reasonMsg = "Explosion";
            default: reasonMsg = "Unknown";
        }
        format(msg, sizeof(msg), "Player %s[%d] has killed %s[%i]. (%s)", killerName, killerid, playerName, playerid, reasonMsg);
        SendMessageToAllAdmins(msg, -1);
    }
    else
    {
        switch (reason)
        {
            case 53: format(msg, sizeof(msg), "Player %s[%d] died. (Drowned)", playerName,playerid);
            case 54: format(msg, sizeof(msg), "Player %s[%d] died. (Collision)", playerName,playerid);
            default: format(msg, sizeof(msg), "Player %s[%d] died.", playerName,playerid);
        }
    }
It works but it doesnt show if the player died of Drowned,Collision or just died it only shows if he died by the weapons
Reply
#2

Put the SendMessageToAllAdmins after all the check(outside the braces).
Reply
#3

maybe
PHP код:
else
        {
            switch (
reason)
            {
                case 
53:  reasonMsg format(msgsizeof(msg), "Player %s[%d] died. (Drowned)"playerName,playerid);
                case 
54reasonMsg format(msgsizeof(msg), "Player %s[%d] died. (Collision)"playerName,playerid);
                default: 
reasonMsg format(msgsizeof(msg), "Player %s[%d] died."playerName,playerid);
               
            }
        }
         
SendMessageToAllAdmins(msg, -1); 
Reply
#4

That worked but now I get these 3 errors on the last 3 cases
Код:
(4495) : error 033: array must be indexed (variable "reasonMsg")
(4496) : error 033: array must be indexed (variable "reasonMsg")
(4497) : error 033: array must be indexed (variable "reasonMsg")
Код:
               case 53: reasonMsg = format(msg, sizeof(msg), "Player %s[%d] died. (Drowned)", playerName,playerid);
                case 54: reasonMsg = format(msg, sizeof(msg), "Player %s[%d] died. (Collision)", playerName,playerid);
                default: reasonMsg = format(msg, sizeof(msg), "Player %s[%d] died.", playerName,playerid);
Reply
#5

Quote:
Originally Posted by Hybris
Посмотреть сообщение
That worked but now I get these 3 errors on the last 3 cases
Код:
(4495) : error 033: array must be indexed (variable "reasonMsg")
(4496) : error 033: array must be indexed (variable "reasonMsg")
(4497) : error 033: array must be indexed (variable "reasonMsg")
Код:
               case 53: reasonMsg = format(msg, sizeof(msg), "Player %s[%d] died. (Drowned)", playerName,playerid);
                case 54: reasonMsg = format(msg, sizeof(msg), "Player %s[%d] died. (Collision)", playerName,playerid);
                default: reasonMsg = format(msg, sizeof(msg), "Player %s[%d] died.", playerName,playerid);
You cant do that and dont even need an extra string (msg).
Do it like this:
pawn Код:
format(reasonMsg, sizeof reasonMsg, "Player %s[%d] died. (Drowned)", playerName, playerid);
EDIT: I thought playerName was a function which was a wrong assumption. Just recheck the code. BTW, you could solve that yourself, just a case of concentration.
Reply
#6

My compiler crashes if i do it your way
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)