Problem with params.
#1

Whenever a cop kills a wanted person, he looses cash unless the person became wanted without using the suspect command. The suspect command uses "new ID = strval(params);". When I replaced

"if(GetPlayerWantedLevel(playerid) == 0)"
with
"if(GetPlayerWantedLevel(ID) == 0)"
I obviously got an error. I tried to state what ID was but I don't think I can add it under OnPlayerDeath.
Is there a way?

Код:
}
public OnPlayerDeath(playerid, killerid, reason)
{
	SetPlayerWantedLevel(playerid,0);
	if(killerid == INVALID_PLAYER_ID)
	{
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
        SetPlayerScore(killerid, GetPlayerMoney(killerid));
        SetPlayerWantedLevel(killerid,0);
	}
	else
	{
        if(gTeam[killerid] == Cops)
		{
		    if(gTeam[killerid] != gTeam[playerid])
		    {
          		if(GetPlayerWantedLevel(ID) == 0)
		        {
Reply
#2

Can't you just use:

pawn Код:
if(GetPlayerWantedLevel(killerid) == 0)
Or am I missing the point?
Reply
#3

Thanks for the reply, unfortunately...that won't fix it.

"ID" is used to describe the person that will become wanted, "killerid" won't match.
I'm currently using "playerid" in this code:
if(GetPlayerWantedLevel(killerid) == 0)

The cop would receive a warning that he killed an innocent player. That's why they both need to be ID.
I hope you understand what I mean.
Reply
#4

I think you just mean playerid? Because this is called when that person dies. If playerid's Wanted level is 0 and killerid is a cop, then you can send a message and take cash from killerid, which would be the cop. Again, unless I also misinterpreted it.
Reply
#5

Well if you want to check the wanted level of the person who was killed then it's always going to be 0 since you set it to 0 at the very start of OnPlayerDeath, the check should be done before resetting his wanted level.
Reply
#6

I don't think you're all getting what I mean.
I still want the cop to get a message when he kills an innocent person...

I have a command that check's who's wanted. If a cop kills the wanted person he gets that message. It's because:
"if(GetPlayerWantedLevel(killerid) == 0)"
needs to be
"if(GetPlayerWantedLevel(ID) == 0)".


I have to reveal my suspect script for you to explain.
ID = the person that is going to be wanted.
playerid isn't. So when I try to add "new ID =...." under onplayerdeath, I get a params error.

Код:
dcmd_sus1(const playerid,const params[])
{
    new ID = strval(params);
    if(gTeam[playerid] == Cops && gTeam[ID] != Cops)
    {
        new name[MAX_PLAYER_NAME], string[48];
		GetPlayerName(ID, name, sizeof(name));
		format(string, sizeof(string), "%s is now wanted by the police.", name );
 		SendClientMessageToAll(COLOR_RED, string);
		return SendClientMessage(ID,0xf9f9f9f9,"You are now wanted by the police."), SetPlayerWantedLevel(ID, 3);
Update.
I removed new ID = strval(params); from the above script.
That resulted in me adding myself as wanted. Obviously it didn't work because the following bit doesn't allow it.
So obviously I needed replace playerid with another word.
"if(gTeam[playerid] == Cops && gTeam[ID] != Cops)"
Reply
#7

But ID is playerid in OnPlayerDeath, because it contains the ID of the player who was killed.

If you want it to be ID...then add ID = playerid.

I think you are the one who is a little confused.

ID is a variable, not a specific ID, a variable can be called anything, or be anything, and in the instance of OnPlayerDeath, the person killed is playerid, which is your "ID", I'm pretty sure if you try it you'll get what you need.

Just try this:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    // SetPlayerWantedLevel(playerid,0); It has to be removed from here and put later or else it won't work
    if(killerid == INVALID_PLAYER_ID)
    {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
        SetPlayerScore(killerid, GetPlayerMoney(killerid));
        SetPlayerWantedLevel(killerid,0);
    }
    else
    {
        if(gTeam[killerid] == Cops)
        {
            if(gTeam[killerid] != gTeam[playerid])
            {
                if(GetPlayerWantedLevel(playerid) == 0)
                {
                    SendClientMessage(killerid,COLOR_RED,"You killed an innocent person!");
Reply
#8

It worked! Thanks a lot!
Sorry for the confusion and thanks a lot for fixing the fix
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)