SA-MP Forums Archive
Will this work? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Will this work? (/showthread.php?tid=168098)



Will this work? - Ihsan_Cingisiz - 14.08.2010

Hello, i tried the suicide script but i don't get the ClientMessage,
i didn't try the if someone else kills me but what did i do wrong?

Quote:

public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[playerid][pDeaths] += 1;

if(killerid != INVALID_PLAYER_ID)
{
new str[256];
new name1[256];
new name2[256];
GetPlayerName(playerid, name1, sizeof(name1));
GetPlayerName(killerid, name2, sizeof(name2));
format(str, sizeof(str), "» You hunted %s(%i) down, gained: $10000 | Killer: %s(%i)", name1, playerid, name2, killerid);
GivePlayerMoney(killerid, 10000);
PlayerInfo[killerid][pKills] += 1;
SendDeathMessage(killerid, playerid, reason);
SendClientMessage(killerid, COLOR_LIGHTBLUE, "[=================| BOOM |=================]");
SendClientMessage(killerid, COLOR_GRAD1, str);
SendClientMessage(killerid, COLOR_LIGHTBLUE, "[=================| BOOM |=================]");
return 1;
}
else
{
SendClientMessage(killerid, COLOR_LIGHTBLUE, "[=================| BOOM |=================]");
SendClientMessage(killerid, COLOR_GRAD1, "You have commited suicide.");
SendClientMessage(killerid, COLOR_LIGHTBLUE, "[=================| BOOM |=================]");
return 1;
}
}




Re: Will this work? - gamer931215 - 14.08.2010

First try instead of:
pawn Код:
GetPlayerName(playerid, name1, sizeof(name1));
doing
pawn Код:
GetPlayerName(playerid, name1, sizeof name1);
(same with strings etc)


Second, check your strings for maybe conflicting characters (" ; ' [] = etc.) which wont make it appear.

Else i dont know


Re: Will this work? - Niixie - 14.08.2010

Quote:
Originally Posted by gamer931215
Посмотреть сообщение
First try instead of:
pawn Код:
GetPlayerName(playerid, name1, sizeof(name1));
doing
pawn Код:
GetPlayerName(playerid, name1, sizeof name1);
Will not work, those two things does the same. just to mention

OT:
Ofc it will not work.
you cant say else to if(killerid != INVALID_PLAYER_ID)

if killerid and playerid is equal, then its suicide ...
and insted of PlayerInfo[killerid][pDeaths] += 1;
try
PlayerInfo[killerid][pDeaths]++;


Re: Will this work? - Ihsan_Cingisiz - 14.08.2010

Quote:
Originally Posted by gamer931215
Посмотреть сообщение
First try instead of:
pawn Код:
GetPlayerName(playerid, name1, sizeof(name1));
doing
pawn Код:
GetPlayerName(playerid, name1, sizeof name1);
(same with strings etc)


Second, check your strings for maybe conflicting characters (" ; ' [] = etc.) which wont make it appear.

Else i dont know
I checked everything, everything is correct but it doesn't display..
I need help from a more professional Pawno scripter then..

The GetPlayerName are good.. sizeof's is everytime with two () like sizeof(xd) and to close sizeof(xd));


Re: Will this work? - Ihsan_Cingisiz - 14.08.2010

Quote:
Originally Posted by Niixie
Посмотреть сообщение
Will not work, those two things does the same. just to mention
hehe, thanks didn't see..

Still need help


Re: Will this work? - Niixie - 14.08.2010

i edited my post before
also
remember, NAME STRINGS NEEDS TO BE SIZE "MAX_PLAYER_NAME"!
Its a rule you need to write in your head!


Re: Will this work? - Ihsan_Cingisiz - 14.08.2010

Quote:
Originally Posted by Niixie
Посмотреть сообщение
Will not work, those two things does the same. just to mention

OT:
Ofc it will not work.
you cant say else to if(killerid != INVALID_PLAYER_ID)

if killerid and playerid is equal, then its suicide ...
and insted of PlayerInfo[killerid][pDeaths] += 1;
try
PlayerInfo[killerid][pDeaths]++;
But i don't get the suicide part.. Can you post a little script example
dont understand exactly


Re: Will this work? - Ihsan_Cingisiz - 14.08.2010

Quote:
Originally Posted by Ihsan_Cingisiz
Посмотреть сообщение
But i don't get the suicide part.. Can you post a little script example
dont understand exactly
... .


Re: Will this work? - gamer931215 - 14.08.2010

I think he means

1: That if(killerid != INVALID_PLAYER_ID) is incorrect (try something else maybe if killerid == playerid then its suicide, else its kill or something like that).

2: Try instead of PlayerInfo[killerid][pDeaths] += 1;
PlayerInfo[killerid][pDeaths]++;


Re: Will this work? - PotH3Ad - 15.08.2010

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[playerid][pDeaths] += 1;

    if(killerid == INVALID_PLAYER_ID) //If their is no killer
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "[=================| BOOM |=================]");
        SendClientMessage(playerid, COLOR_GRAD1, "You have commited suicide.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "[=================| BOOM |=================]");
    }
    else if(killerid != INVALID_PLAYER_ID) //else if their is a killer
    {
        new str[200];
        new name1[MAX_PLAYER_NAME];
        new name2[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name1, sizeof(name1));
        GetPlayerName(killerid, name2, sizeof(name2));
        format(str, sizeof(str), "» You hunted %s(%i) down, gained: $10000 | Killer: %s(%i)", name1, playerid, name2, killerid);
        GivePlayerMoney(killerid, 10000);
        PlayerInfo[killerid][pKills] += 1;
        SendDeathMessage(killerid, playerid, reason);
        SendClientMessage(killerid, COLOR_LIGHTBLUE, "[=================| BOOM |=================]");
        SendClientMessage(killerid, COLOR_GRAD1, str);
        SendClientMessage(killerid, COLOR_LIGHTBLUE, "[=================| BOOM |=================]");
    }
    return 1;
}