Problem with bounty
#1

Hi,im coding a bounty system (if you kill 3+ swat member u get 3 stars level + 1000$ every swat killed).

I done this:

Код:
new Bounty[MAX_PLAYERS];
new BountyKills[MAX_PLAYERS];
OnPlayerConnect

Код:
 Bounty[playerid] = 0;
   	BountyKills[playerid] = 0;
OnPlayerDeath

Код:
 new str[128];
    if(IsPlayerJustice(playerid) && !IsPlayerJustice(killerid))
			{
			BountyKills[killerid]++;
			if(BountyKills[killerid] > 3)
			{
			if(BountyKills[killerid] == 4) Bounty[killerid] = 10000;
			else Bounty[killerid] += 2500;
			GetName(killerid, killername);
			format(str, sizeof(str), "%s (%d) now has a bounty of $%d", killername, killerid, Bounty[killerid]);
			SendClientMessageToAll(COLOR_YELLOW, str);
				}
			}
			if(Bounty[playerid] > 0)
			{
		    GetName(playerid, playername);
			GivePlayerMoney(killerid, Bounty[playerid]);
			format(str, sizeof(str), "You got $%d bounty reward for killing %s (%d)", Bounty[playerid], playername, playerid);
			SendClientMessage(killerid, COLOR_YELLOW, str);
			}
		}
   	}
   	Bounty[playerid] = 0;
   	BountyKills[playerid] = 0;
The IsPlayerJustice function:

Код:
IsPlayerJustice(playerid)
{
	if(gTeam[playerid] == TEAM_SWAT return 1;
	else return 0;
}
And i get tons of errors:

Код:
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2056) : warning 219: local variable "reasonMsg" shadows a variable at a preceding level
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2170) : error 001: expected token: ")", but found "return"
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2201) : error 054: unmatched closing brace ("}")
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2205) : error 021: symbol already defined: "GetPlayerName"
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2207) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2209) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2211) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2215) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2219) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2223) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2227) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2231) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2235) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2239) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2243) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2247) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2251) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2255) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2259) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2263) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2267) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2271) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2275) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2279) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2283) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2287) : error 010: invalid function or declaration
C:\Documents and Settings\k\Desktop\SFWAR.pwn(2291) : error 010: invalid function or declaration

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.
What i done wrong?Thanks!
Reply
#2

Mark these lines, we don't know which line is e.x. 2211.
Reply
#3

pawn Код:
new str[128];
    if(IsPlayerJustice(playerid) && !IsPlayerJustice(killerid)) {
        BountyKills[killerid]++;
        if(BountyKills[killerid] > 3) {
            if(BountyKills[killerid] == 4) Bounty[killerid] = 10000;
            else Bounty[killerid] += 2500;
            GetName(killerid, killername);
            format(str, sizeof(str), "%s (%d) now has a bounty of $%d", killername, killerid, Bounty[killerid]);
            SendClientMessageToAll(COLOR_YELLOW, str);
        }
    }
    if(Bounty[playerid] > 0) {
        GetName(playerid, playername);
        GivePlayerMoney(killerid, Bounty[playerid]);
        format(str, sizeof(str), "You got $%d bounty reward for killing %s (%d)", Bounty[playerid], playername, playerid);
        SendClientMessage(killerid, COLOR_YELLOW, str);
    }
}


Bounty[playerid] = 0;
BountyKills[playerid] = 0;
Try that, seems like you added a extra bracket..
Reply
#4

Same errors...
Reply
#5

Quote:
Originally Posted by rs.pect
Посмотреть сообщение
Mark these lines, we don't know which line is e.x. 2211.
I would help you if you would want to.

Mark, where are 2056, 2170, 2201, 2205 and the rest or give whole code (can be on PM).
Reply
#6

Sorry rs.pect here are the lines:

Line 2170:

Код:
if(gTeam[playerid] == TEAM_SWAT return 1;
Line 2201:

Код:
}
Line 2205

Код:
GetPlayerName(killerid, killerName, sizeof(killerName));
Line 2207

Код:
if (killerid != INVALID_PLAYER_ID)
Line 2209

Код:
switch (reason)
Line 2311

Код:
case 31:
Line 2315

Код:
switch (GetVehicleModel(GetPlayerVehicleID(killerid)))
Line 2319

Код:
reasonMsg = "Sea Sparrow Machine Gun";
Line 2223

Код:
reasonMsg = "M4";
Line 2227

Код:
else
Line 2231

Код:
}
Line 2235

Код:
}
Line 2339

Код:
}
And same lines...
Reply
#7

2170:
pawn Код:
if(gTeam[playerid] == TEAM_SWAT return 1;
2201:
try removing this brace

2205:
probably you've put this line out of any functions and compilator thinks it's a new function

for rest of lines, show little bit more code (1 line before and 1 line after).
Reply
#8

This are the last error lines,but i dont think are wrong because i get this errors only when i add the bounty code.

Код:
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";
			}
Reply
#9

pawn Код:
if(gTeam[playerid] == TEAM_SWAT) return 1;
What other errors?
Reply
#10

The errors are "invalid function or declaration" and i've listed the affected lines above your post.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)