Death message error
#1

Whenever i input this in OnPlayerDeath my compiler stops working I don't see anything wrong with it though may I be assisted please?
Код:
if (killerid != INVALID_PLAYER_ID)
    {
        switch (reason)
        {
      	    new string[300];
            case 0: reason = "Unarmed";
            case 1: reason = "Brass Knuckles";
            case 2: reason = "Golf Club";
            case 3: reason = "Night Stick";
            case 4: reason = "Knife";
            case 5: reason = "Baseball Bat";
            case 6: reason = "Shovel";
            case 7: reason = "Pool Cue";
            case 8: reason = "Katana";
            case 9: reason = "Chainsaw";
            case 10: reason = "Dildo";
            case 11: reason = "Dildo";
            case 12: reason = "Vibrator";
            case 13: reason = "Vibrator";
            case 14: reason = "Flowers";
            case 15: reason = "Cane";
            case 22: reason = "Pistol";
            case 23: reason = "Silenced Pistol";
            case 24: reason = "Desert Eagle";
            case 25: reason = "Shotgun";
            case 26: reason = "Sawn-off Shotgun";
            case 27: reason = "Combat Shotgun";
            case 28: reason = "MAC-10";
            case 29: reason = "MP5";
            case 30: reason = "AK-47";
            case 31: reason = "M4";
            case 32: reason = "TEC-9";
            case 33: reason = "Country Rifle";
            case 34: reason = "Sniper Rifle";
            case 37: reason = "Fire";
            case 38: reason = "Minigun";
            case 41: reason = "Spray Can";
            case 42: reason = "Fire Extinguisher";
            case 49: reason = "Vehicle Collision";
            case 50: reason = "Vehicle Collision";
            case 51: reason = "Explosion";
            default: reason = "Unknown";
        }
        format(string, sizeof(string), "Player %s[%i] has killed %s[%i]. (%s)", killerid, playerid, PlayerName, playerid, reason);
    }
    else
    {
        switch (reason)
        {
            case 53: format(string, sizeof(string), "Player %s[%i] died. (Drowned)", PlayerName,playerid);
            case 54: format(string, sizeof(string), "Player %s[%i] died. (Collision)", PlayerName,playerid);
            default: format(string, sizeof(string), "Player %s[%i] died.", PlayerName,playerid);
        }
    }
Reply
#2

string size is too big use 32 and use another string for format msg

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

try this, includes more reason.. and fixed
pawn Код:
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:
          {
             if(GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
             {
                switch (GetVehicleModel(GetPlayerVehicleID(killerid)))
                {
                   case 447: { reasonMsg = "Sea Sparrow Machine Gun"; }
                   default: { reasonMsg = "M4"; }
                }
             }
             else
             {
                reasonMsg = "M4";
             }
          }
          case 32: { reasonMsg = "TEC-9"; }
          case 33: { reasonMsg = "Rifle"; }
          case 34: { reasonMsg = "Sniper Rifle"; }
          case 37: { reasonMsg = "Fire"; }
          case 38:
          {
             if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
             {
                switch (GetVehicleModel(GetPlayerVehicleID(killerid)))
                {
                   case 425: { reasonMsg = "Hunter Machine Gun"; }
                   default: { reasonMsg = "Minigun"; }
                }
             }
             else { reasonMsg = "Minigun"; }
          }
          case 41: { reasonMsg = "Spraycan"; }
          case 42: { reasonMsg = "Fire Extinguisher"; }
          case 49: { reasonMsg = "Vehicle Collision"; }
          case 50:
          {
             if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
             {
                switch (GetVehicleModel(GetPlayerVehicleID(killerid)))
                {
                   case 417, 425, 447, 465, 469, 487, 488, 497, 501, 548, 563: { reasonMsg = "Helicopter Blades"; }
                   default: { reasonMsg = "Vehicle Collision"; }
                }
             }
             else { reasonMsg = "Vehicle Collision"; }
          }
          case 51:
          {
             if (GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
             {
                switch (GetVehicleModel(GetPlayerVehicleID(killerid)))
                {
                   case 425: { reasonMsg = "Hunter Rockets"; }
                   case 432: { reasonMsg = "Rhino Turret"; }
                   case 520: { reasonMsg = "Hydra Rockets"; }
                   default: { reasonMsg = "Explosion"; }
                }
             }
             else { reasonMsg = "Explosion"; }
          }
          default: { reasonMsg = "Unknown"; }
       }
       new pName[MAX_PLAYER_NAME], kName[MAX_PLAYER_NAME];
       GetPlayerName(playerid, pName, sizeof(pName));
       GetPlayerName(killerid, kName, sizeof(kName));
       format(string, sizeof(string), "Player %s[%d] has killed %s[%d]. (%s)", kName, killerid, pName, playerid, reasonMsg);
    }
    else
    {
       new pName[MAX_PLAYER_NAME];
       GetPlayerName(playerid, pName, sizeof(pName));
       switch(reason)
       {
          case 53:
          {
             format(string, sizeof(string), "Player %s[%d] died. (Drowned)", pName, playerid);
          }
          case 54:
          {
             format(string, sizeof(string), "Player %s[%d] died. (Collision)", pName, playerid);
          }
          default:
          {
             format(string, sizeof(string), "Player %s[%d] died.", pName, playerid);
          }
       }
    }
Reply
#4

Quote:
Originally Posted by Namer
Посмотреть сообщение
string size is too big use 32 and use another string for format msg

PHP код:
    new msg[128], killerName[MAX_PLAYER_NAME], reasonMsg[32], playerName[MAX_PLAYER_NAME];
    
GetPlayerName(killeridkillerNamesizeof(killerName));
    
GetPlayerName(playeridplayerNamesizeof(playerName));
        if (
killerid != INVALID_PLAYER_ID)
    {
        switch (
reason)
        {
            case 
0reasonMsg "Unarmed";
            case 
1reasonMsg "Brass Knuckles";
            case 
2reasonMsg "Golf Club";
            case 
3reasonMsg "Night Stick";
            case 
4reasonMsg "Knife";
            case 
5reasonMsg "Baseball Bat";
            case 
6reasonMsg "Shovel";
            case 
7reasonMsg "Pool Cue";
            case 
8reasonMsg "Katana";
            case 
9reasonMsg "Chainsaw";
            case 
10reasonMsg "Dildo";
            case 
11reasonMsg "Dildo";
            case 
12reasonMsg "Vibrator";
            case 
13reasonMsg "Vibrator";
            case 
14reasonMsg "Flowers";
            case 
15reasonMsg "Cane";
            case 
22reasonMsg "Pistol";
            case 
23reasonMsg "Silenced Pistol";
            case 
24reasonMsg "Desert Eagle";
            case 
25reasonMsg "Shotgun";
            case 
26reasonMsg "Sawn-off Shotgun";
            case 
27reasonMsg "Combat Shotgun";
            case 
28reasonMsg "MAC-10";
            case 
29reasonMsg "MP5";
            case 
30reasonMsg "AK-47";
            case 
31reasonMsg "M4";
            case 
32reasonMsg "TEC-9";
            case 
33reasonMsg "Country Rifle";
            case 
34reasonMsg "Sniper Rifle";
            case 
37reasonMsg "Fire";
            case 
38reasonMsg "Minigun";
            case 
41reasonMsg "Spray Can";
            case 
42reasonMsg "Fire Extinguisher";
            case 
49reasonMsg "Vehicle Collision";
            case 
50reasonMsg "Vehicle Collision";
            case 
51reasonMsg "Explosion";
            default: 
reasonMsg "Unknown";
        }
        
format(msgsizeof(msg), "04*** %s killed %s. (%s)"killerNameplayerNamereasonMsg);
    }
    else
    {
        switch (
reason)
        {
            case 
53format(msgsizeof(msg), "04*** %s died. (Drowned)"playerName);
            case 
54format(msgsizeof(msg), "04*** %s died. (Collision)"playerName);
            default: 
format(msgsizeof(msg), "04*** %s died."playerName);
        }
    } 
Thx mate +rep who tried helping out case closed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)