Police System Send Crime Report (OnPlayerDeath)
#1

So here is my issue I am trying to add a "Crime Report" that is sent to the the Police when a player kills another player Via (OnPlayerDeath), well so far it works, it does give killerid a wanted level if they killed another player. But.. if a player dies (from a non valid reason, suicide, fall, exposion, fire etc..) It will get sent to the police channel though they haven't killed anyone, But they DO NOT GET A WANTED LEVEL, and the police channel is sent a bogus message..

Note: I am a officer, it is not sending to all the players.
Screenshot was for reference.

This is the code I am working with..

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	new oldlevel;
 	new newlevel;
  	oldlevel = GetPlayerWantedLevel(killerid);
   	newlevel = oldlevel + 1;
    //if(!(killerid) && reason != 53) SendDeathMessage(killerid, playerid, reason); // Doesn't work..
    SetPlayerWantedLevel(killerid, newlevel);
    //SetPlayerWantedLevel(playerid, 0); // Removes wanted players killer, wanted level
	SendClientMessage(killerid, COP_COLOR ,"You have committed a crime, FIRST DEGREE MURDER.");
    new string[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
   	format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
	//PlayCrimeReportForPlayer(string, 0, 3); //Not implemented yet
	return TeamChat(string);

}
I have attached a screenshot of it in game aswell.

Reply
#2

Use this instead of PlayerCrimeReportForPlayer:
PHP код:
iteam=GetPlayerTeam(i);
if(
iteam==TEAM_COPS || iteam==TEAM_SWAT || iteam==TEAM_ARMY)
{
    new 
string[128], location[128];
    
GetPlayer2DZone(playeridlocationMAX_ZONE_NAME);
    
format(stringsizeof(string), "ATTEMPTED ESCAPE: %s has escaped from his handcuffs. Location: %s."playernamelocation);
    
SendClientMessage(iCOLOR_CRIMEstring);
    
SendClientMessage(iCOLOR_CRIME"DISPATCH: All units in this area, please respond.");

This is from my script.
Reply
#3

I am not using PlayerCrimeReportForPlayer: I am using OnPlayerDeath. O.o
Reply
#4

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new oldlevel;
    new newlevel;
    oldlevel = GetPlayerWantedLevel(killerid);
    newlevel = oldlevel + 1;
    if(killerid != INVALID_PLAYER_ID)
    {
        //if(!(killerid) && reason != 53) SendDeathMessage(killerid, playerid, reason); // Doesn't work..
        SetPlayerWantedLevel(killerid, newlevel);
        //SetPlayerWantedLevel(playerid, 0); // Removes wanted players killer, wanted level
        SendClientMessage(killerid, COP_COLOR ,"You have committed a crime, FIRST DEGREE MURDER.");
        new string[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
        //PlayCrimeReportForPlayer(string, 0, 3); //Not implemented yet
    }
    return TeamChat(string);

}
Reply
#5

Quote:
Originally Posted by iThePunisher
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new oldlevel;
    new newlevel;
    oldlevel = GetPlayerWantedLevel(killerid);
    newlevel = oldlevel + 1;
    if(killerid != INVALID_PLAYER_ID)
    {
        //if(!(killerid) && reason != 53) SendDeathMessage(killerid, playerid, reason); // Doesn't work..
        SetPlayerWantedLevel(killerid, newlevel);
        //SetPlayerWantedLevel(playerid, 0); // Removes wanted players killer, wanted level
        SendClientMessage(killerid, COP_COLOR ,"You have committed a crime, FIRST DEGREE MURDER.");
        new string[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
        //PlayCrimeReportForPlayer(string, 0, 3); //Not implemented yet
    }
    return TeamChat(string);

}
So I tried that, compiled and I got this "(1205) : error 017: undefined symbol "string""

which is this

Код:
return TeamChat(string);
Which is used like this..

Код:
new string[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
   	format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
	return TeamChat(string);
But above ^ is causing the error..

and I also tried the code you gave like this.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new oldlevel;
    new newlevel;
    oldlevel = GetPlayerWantedLevel(killerid);
    newlevel = oldlevel + 1;
    if(killerid != INVALID_PLAYER_ID)
    {
        //if(!(killerid) && reason != 53) SendDeathMessage(killerid, playerid, reason); // Doesn't work..
        SetPlayerWantedLevel(killerid, newlevel);
        //SetPlayerWantedLevel(playerid, 0); // Removes wanted players killer, wanted level
        SendClientMessage(killerid, COP_COLOR ,"You have committed a crime, FIRST DEGREE MURDER.");
        //PlayCrimeReportForPlayer(string, 0, 3); //Not implemented yet
    }
    new string[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
    return TeamChat(string);

}
and compiled in which it did, but I am still getting the SAME exact results as I was before.

I think problem is in this string here:

Код:
new string[256], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
    return TeamChat(string);
But I have no idea how to fix it.
Reply
#6

Try this:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    //if(!(killerid) && reason != 53) SendDeathMessage(killerid, playerid, reason); // Doesn't work..
    if(killerid != INVALID_PLAYER_ID) // Let's confirm that the killerid is connected to the server
    {
        SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1);
        //SetPlayerWantedLevel(playerid, 0); // Removes wanted players killer, wanted level
        SendClientMessage(killerid, COP_COLOR ,"You have committed a crime, FIRST DEGREE MURDER.");
        new string[128], name[MAX_PLAYER_NAME]; GetPlayerName(killerid, name, sizeof(name));
        format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
    //PlayCrimeReportForPlayer(string, 0, 3); //Not implemented yet
        TeamChat(string);
    }
    return 1;
}
PS: Members in the forum, totally copy others code for reputation points...
Reply
#7

You are sending a crime report even if there is no killer. Also, I think you meant to use killerid instead of playerid in that GetPlayerName thingy, since the killer is the suspect, not the victim.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new oldlevel;
    new newlevel;
    oldlevel = GetPlayerWantedLevel(killerid);
    newlevel = oldlevel + 1;
    if(killerid != INVALID_PLAYER_ID)
    {
        //if(!(killerid) && reason != 53) SendDeathMessage(killerid, playerid, reason); // Doesn't work..
        SetPlayerWantedLevel(killerid, newlevel);
        //SetPlayerWantedLevel(playerid, 0); // Removes wanted players killer, wanted level
        SendClientMessage(killerid, COP_COLOR ,"You have committed a crime, FIRST DEGREE MURDER.");
        //PlayCrimeReportForPlayer(string, 0, 3); //Not implemented yet
        new string[256], name[MAX_PLAYER_NAME]; GetPlayerName(killerid, name, sizeof(name));
        format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
        TeamChat(string);
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by biker122
Посмотреть сообщение
Try this:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    //if(!(killerid) && reason != 53) SendDeathMessage(killerid, playerid, reason); // Doesn't work..
    if(killerid != INVALID_PLAYER_ID) // Let's confirm that the killerid is connected to the server
    {
        SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1);
        //SetPlayerWantedLevel(playerid, 0); // Removes wanted players killer, wanted level
        SendClientMessage(killerid, COP_COLOR ,"You have committed a crime, FIRST DEGREE MURDER.");
        new string[128], name[MAX_PLAYER_NAME]; GetPlayerName(killerid, name, sizeof(name));
        format(string, sizeof(string), "NEW CRIME REPORT: First Degree Murder, SUSPECT: {AFAFAF}%s{375FFF}", name);
    //PlayCrimeReportForPlayer(string, 0, 3); //Not implemented yet
        TeamChat(string);
    }
    return 1;
}
Dude. You are my hero. That fixed it for sure! Rep++
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)