KillerID Problem
#1

Hello, im currently remaking a gamemode from GTA V (Further details to be released soon), as I mentioned in my last post, but there is a problem with GetPlayerName, but luckily no errors. The killer's name won't show within the chat (Just a side note, people are being eliminated via vehicle vs vehicle)

Here's some code;

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
 	playerveh = GetPlayerVehicleID(playerid);
	DestroyVehicle(playerveh);
    SendDeathMessage(killerid, playerid, reason);
	SetPlayerScore(killerid,GetPlayerScore(killerid)+5);
	SetPlayerScore(playerid,GetPlayerScore(playerid)-1);
	GivePlayerMoney(killerid, 100000);
	GivePlayerMoney(playerid, -15000);
	PlayerPlaySound(playerid, 1085, 0.0, 0.0, 10.0);
    new pID_name[MAX_PLAYER_NAME], killerID_name[MAX_PLAYER_NAME], Message[128];
    GetPlayerName(playerid, pID_name, MAX_PLAYER_NAME);
    GetPlayerName(killerid, killerID_name, MAX_PLAYER_NAME);
    switch(random(56))
    {
        case 0: format(Message, sizeof(Message), "%s beat down %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 1: format(Message, sizeof(Message), "%s smashed %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_GREEN, Message);
        case 2: format(Message, sizeof(Message), "%s butchered %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 3: format(Message, sizeof(Message), "%s cut up %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_YELLOW, Message);
        case 4: format(Message, sizeof(Message), "%s spiked %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 5: format(Message, sizeof(Message), "%s striped %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 6: format(Message, sizeof(Message), "%s capped %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 7: format(Message, sizeof(Message), "%s clocked %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 8: format(Message, sizeof(Message), "%s pistoled %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 9: format(Message, sizeof(Message), "%s smoked %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 10: format(Message, sizeof(Message), "%s whacked %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 11: format(Message, sizeof(Message), "%s 12 bored %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 12: format(Message, sizeof(Message), "%s blew away %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 13: format(Message, sizeof(Message), "%s farmed %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 14: format(Message, sizeof(Message), "%s opened up %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 15: format(Message, sizeof(Message), "%s perforated %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 16: format(Message, sizeof(Message), "%s shelled %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 17: format(Message, sizeof(Message), "%s put a load in %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 18: format(Message, sizeof(Message), "%s cancelled %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 19: format(Message, sizeof(Message), "%s crossed out %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 20: format(Message, sizeof(Message), "%s cut down %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 21: format(Message, sizeof(Message), "%s massacred %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 22: format(Message, sizeof(Message), "%s peppered %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 23: format(Message, sizeof(Message), "%s plugged  %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 24: format(Message, sizeof(Message), "%s riddled %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 25: format(Message, sizeof(Message), "%s sprayed %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 26: format(Message, sizeof(Message), "%s ventilated  %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 27: format(Message, sizeof(Message), "%s 3rd worlded %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 28: format(Message, sizeof(Message), "%s armied %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 29: format(Message, sizeof(Message), "%s drilled %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 30: format(Message, sizeof(Message), "%s ended %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 31: format(Message, sizeof(Message), "%s killed %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 32: format(Message, sizeof(Message), "%s machined %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 33: format(Message, sizeof(Message), "%s terminated  %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 34: format(Message, sizeof(Message), "%s brought down %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 35: format(Message, sizeof(Message), "%s lightning bolted %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 36: format(Message, sizeof(Message), "%s picked off %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 37: format(Message, sizeof(Message), "%s sniped %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 38: format(Message, sizeof(Message), "%s surprised  %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 39: format(Message, sizeof(Message), "%s nailed %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 40: format(Message, sizeof(Message), "%s barbecued %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);//
        case 41: format(Message, sizeof(Message), "%s blazed %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 42: format(Message, sizeof(Message), "%s burnt %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 43: format(Message, sizeof(Message), "%s cooked %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 44: format(Message, sizeof(Message), "%s flame grilled %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 45: format(Message, sizeof(Message), "%s roasted %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_BLUE, Message);
        case 46: format(Message, sizeof(Message), "%s torched %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 47: format(Message, sizeof(Message), "%s atomized %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 48: format(Message, sizeof(Message), "%s blasted %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 49: format(Message, sizeof(Message), "%s blew up %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 50: format(Message, sizeof(Message), "%s detonated %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 51: format(Message, sizeof(Message), "%s f*cked up %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 52: format(Message, sizeof(Message), "%s shocked & awed %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 53: format(Message, sizeof(Message), "%s totaled %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 54: format(Message, sizeof(Message), "%s hit and runned %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
        case 55: format(Message, sizeof(Message), "%s manslaughtered %s!", killerID_name, pID_name), SendClientMessageToAll(COLOR_ORANGE, Message);
	}
}
Reply
#2

Make sure to check that the killerid is not an invalid player.
Reply
#3

replace all the killerID_name with just killerid.
Reply
#4

Quote:
Originally Posted by SwisherSweet
Посмотреть сообщение
replace all the killerID_name with just killerid.
Why? He wants to display the killer name; by doing that his formatting will break completely since it's formatting it as %s ; and that wont fix his issue.
Reply
#5

Oh I didn't relize what he was tryin to do lol...
Reply
#6

Try that
change this :

Код:
    GetPlayerName(playerid, pID_name, MAX_PLAYER_NAME);
    GetPlayerName(killerid, killerID_name, MAX_PLAYER_NAME);
By this

Код:
    GetPlayerName(playerid, pID_name, sizeof(pID_name));
    GetPlayerName(killerid, killerID_name, sizeof(killerID_name));
Reply
#7

This should work:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new playerveh = GetPlayerVehicleID(playerid);
    if(playerveh) DestroyVehicle(playerveh);
    SendDeathMessage(killerid, playerid, reason);
    SetPlayerScore(killerid, GetPlayerScore(killerid) + 5);
    SetPlayerScore(playerid, GetPlayerScore(playerid) - 1);
    GivePlayerMoney(killerid, 100000);
    GivePlayerMoney(playerid, -15000);
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 10.0);
    new player_name[MAX_PLAYER_NAME], killer_name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, player_name, sizeof(player_name));
    GetPlayerName(killerid, killer_name, sizeof(killer_name));
    new msg[75], killedby[20], color = 0xFFFFFFFF;
    switch(random(56))
    {
        case 0: killedby = "beat down", color = COLOR_ORANGE;
        case 1: killedby = "smashed", color = COLOR_GREEN;
        case 2: killedby = "butchered", color = COLOR_BLUE;
        case 3: killedby = "cut up", color = COLOR_YELLOW;
        case 4: killedby = "spiked", color = COLOR_BLUE;
        case 5: killedby = "striped", color = COLOR_ORANGE;
        case 6: killedby = "capped", color = COLOR_ORANGE;
        case 7: killedby = "clocked", color = COLOR_BLUE;
        case 8: killedby = "pistoled", color = COLOR_ORANGE;
        case 9: killedby = "smoked", color = COLOR_ORANGE;
        case 10: killedby = "whacked", color = COLOR_ORANGE;
        case 11: killedby = "12 bored", color = COLOR_BLUE;
        case 12: killedby = "blew away", color = COLOR_ORANGE;
        case 13: killedby = "farmed", color = COLOR_ORANGE;
        case 14: killedby = "opened up", color = COLOR_ORANGE;
        case 15: killedby = "perforated", color = COLOR_ORANGE;
        case 16: killedby = "shelled", color = COLOR_ORANGE;
        case 17: killedby = "put a load in", color = COLOR_BLUE;
        case 18: killedby = "cancelled", color = COLOR_ORANGE;
        case 19: killedby = "crossed out", color = COLOR_ORANGE;
        case 20: killedby = "cut down", color = COLOR_BLUE;
        case 21: killedby = "massacred", color = COLOR_ORANGE;
        case 22: killedby = "peppered", color = COLOR_ORANGE;
        case 23: killedby = "plugged ", color = COLOR_BLUE;
        case 24: killedby = "riddled", color = COLOR_ORANGE;
        case 25: killedby = "sprayed", color = COLOR_ORANGE;
        case 26: killedby = "ventilated ", color = COLOR_ORANGE;
        case 27: killedby = "3rd worlded", color = COLOR_BLUE;
        case 28: killedby = "armied", color = COLOR_ORANGE;
        case 29: killedby = "drilled", color = COLOR_ORANGE;
        case 30: killedby = "ended", color = COLOR_BLUE;
        case 31: killedby = "killed", color = COLOR_ORANGE;
        case 32: killedby = "machined", color = COLOR_ORANGE;
        case 33: killedby = "terminated ", color = COLOR_BLUE;
        case 34: killedby = "brought down", color = COLOR_ORANGE;
        case 35: killedby = "lightning bolted", color = COLOR_ORANGE;
        case 36: killedby = "picked off", color = COLOR_ORANGE;
        case 37: killedby = "sniped", color = COLOR_ORANGE;
        case 38: killedby = "surprised ", color = COLOR_ORANGE;
        case 39: killedby = "nailed", color = COLOR_ORANGE;
        case 40: killedby = "barbecued", color = COLOR_ORANGE;//
        case 41: killedby = "blazed", color = COLOR_BLUE;
        case 42: killedby = "burnt", color = COLOR_ORANGE;
        case 43: killedby = "cooked", color = COLOR_ORANGE;
        case 44: killedby = "flame grilled", color = COLOR_ORANGE;
        case 45: killedby = "roasted", color = COLOR_BLUE;
        case 46: killedby = "torched", color = COLOR_ORANGE;
        case 47: killedby = "atomized", color = COLOR_ORANGE;
        case 48: killedby = "blasted", color = COLOR_ORANGE;
        case 49: killedby = "blew up", color = COLOR_ORANGE;
        case 50: killedby = "detonated", color = COLOR_ORANGE;
        case 51: killedby = "f*cked up", color = COLOR_ORANGE;
        case 52: killedby = "shocked & awed", color = COLOR_ORANGE;
        case 53: killedby = "totaled", color = COLOR_ORANGE;
        case 54: killedby = "hit and runned", color = COLOR_ORANGE;
        case 55: killedby = "manslaughtered", color = COLOR_ORANGE;
    }
    format(msg, sizeof(msg), "%s %s %s!", killer_name, killedby, player_name);
    SendClientMessageToAll(color, msg);
    return 1;
}
It's also easier to edit now. (NOTE: color = 0xFFFFFFFF is just a debug, so if something goes wrong, which it shouldn't, then it will still send a valid client message. With a valid colour.)
Reply
#8

Sorry for the late reply, I'll try those options, I was studying earlier yesterday
Reply
#9

Actually, I should of accounted for invalid killers.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new playerveh = GetPlayerVehicleID(playerid), msg[75], player_name[MAX_PLAYER_NAME];
    if(playerveh) DestroyVehicle(playerveh);
    SendDeathMessage(killerid, playerid, reason);
    GivePlayerMoney(playerid, -15000);
    SetPlayerScore(playerid, GetPlayerScore(playerid) - 1);
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 10.0);
    GetPlayerName(playerid, player_name, sizeof(player_name));
    if(killerid == INVALID_PLAYER_ID || killerid == playerid)
    {
        format(msg, sizeof(msg), "%s died somehow.", player_name);
        SendClientMessageToAll(COLOR_ORANGE, msg);
        return 1;
    }
    SetPlayerScore(killerid, GetPlayerScore(killerid) + 5);
    GivePlayerMoney(killerid, 100000);
    new killer_name[MAX_PLAYER_NAME];
    GetPlayerName(killerid, killer_name, sizeof(killer_name));
    new killedby[20], color = 0xFFFFFFFF;
    switch(random(56))
    {
        case 0: killedby = "beat down", color = COLOR_ORANGE;
        case 1: killedby = "smashed", color = COLOR_GREEN;
        case 2: killedby = "butchered", color = COLOR_BLUE;
        case 3: killedby = "cut up", color = COLOR_YELLOW;
        case 4: killedby = "spiked", color = COLOR_BLUE;
        case 5: killedby = "striped", color = COLOR_ORANGE;
        case 6: killedby = "capped", color = COLOR_ORANGE;
        case 7: killedby = "clocked", color = COLOR_BLUE;
        case 8: killedby = "pistoled", color = COLOR_ORANGE;
        case 9: killedby = "smoked", color = COLOR_ORANGE;
        case 10: killedby = "whacked", color = COLOR_ORANGE;
        case 11: killedby = "12 bored", color = COLOR_BLUE;
        case 12: killedby = "blew away", color = COLOR_ORANGE;
        case 13: killedby = "farmed", color = COLOR_ORANGE;
        case 14: killedby = "opened up", color = COLOR_ORANGE;
        case 15: killedby = "perforated", color = COLOR_ORANGE;
        case 16: killedby = "shelled", color = COLOR_ORANGE;
        case 17: killedby = "put a load in", color = COLOR_BLUE;
        case 18: killedby = "cancelled", color = COLOR_ORANGE;
        case 19: killedby = "crossed out", color = COLOR_ORANGE;
        case 20: killedby = "cut down", color = COLOR_BLUE;
        case 21: killedby = "massacred", color = COLOR_ORANGE;
        case 22: killedby = "peppered", color = COLOR_ORANGE;
        case 23: killedby = "plugged ", color = COLOR_BLUE;
        case 24: killedby = "riddled", color = COLOR_ORANGE;
        case 25: killedby = "sprayed", color = COLOR_ORANGE;
        case 26: killedby = "ventilated ", color = COLOR_ORANGE;
        case 27: killedby = "3rd worlded", color = COLOR_BLUE;
        case 28: killedby = "armied", color = COLOR_ORANGE;
        case 29: killedby = "drilled", color = COLOR_ORANGE;
        case 30: killedby = "ended", color = COLOR_BLUE;
        case 31: killedby = "killed", color = COLOR_ORANGE;
        case 32: killedby = "machined", color = COLOR_ORANGE;
        case 33: killedby = "terminated ", color = COLOR_BLUE;
        case 34: killedby = "brought down", color = COLOR_ORANGE;
        case 35: killedby = "lightning bolted", color = COLOR_ORANGE;
        case 36: killedby = "picked off", color = COLOR_ORANGE;
        case 37: killedby = "sniped", color = COLOR_ORANGE;
        case 38: killedby = "surprised ", color = COLOR_ORANGE;
        case 39: killedby = "nailed", color = COLOR_ORANGE;
        case 40: killedby = "barbecued", color = COLOR_ORANGE;//
        case 41: killedby = "blazed", color = COLOR_BLUE;
        case 42: killedby = "burnt", color = COLOR_ORANGE;
        case 43: killedby = "cooked", color = COLOR_ORANGE;
        case 44: killedby = "flame grilled", color = COLOR_ORANGE;
        case 45: killedby = "roasted", color = COLOR_BLUE;
        case 46: killedby = "torched", color = COLOR_ORANGE;
        case 47: killedby = "atomized", color = COLOR_ORANGE;
        case 48: killedby = "blasted", color = COLOR_ORANGE;
        case 49: killedby = "blew up", color = COLOR_ORANGE;
        case 50: killedby = "detonated", color = COLOR_ORANGE;
        case 51: killedby = "f*cked up", color = COLOR_ORANGE;
        case 52: killedby = "shocked & awed", color = COLOR_ORANGE;
        case 53: killedby = "totaled", color = COLOR_ORANGE;
        case 54: killedby = "hit and runned", color = COLOR_ORANGE;
        case 55: killedby = "manslaughtered", color = COLOR_ORANGE;
    }
    format(msg, sizeof(msg), "%s %s %s!", killer_name, killedby, player_name);
    SendClientMessageToAll(color, msg);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)