Problem with bounty -
Face9000 - 18.12.2010
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!
Re: Problem with bounty -
rs.pect - 18.12.2010
Mark these lines, we don't know which line is e.x. 2211.
Re: Problem with bounty -
Lorenc_ - 18.12.2010
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..
Re: Problem with bounty -
Face9000 - 18.12.2010
Same errors...
Re: Problem with bounty -
rs.pect - 18.12.2010
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).
Re: Problem with bounty -
Face9000 - 18.12.2010
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
Line 2311
Line 2315
Код:
switch (GetVehicleModel(GetPlayerVehicleID(killerid)))
Line 2319
Код:
reasonMsg = "Sea Sparrow Machine Gun";
Line 2223
Line 2227
Line 2231
Line 2235
Line 2339
And same lines...
Re: Problem with bounty -
rs.pect - 18.12.2010
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).
Re: Problem with bounty -
Face9000 - 18.12.2010
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";
}
Re: Problem with bounty -
Lorenc_ - 18.12.2010
pawn Код:
if(gTeam[playerid] == TEAM_SWAT) return 1;
What other errors?
Re: Problem with bounty -
Face9000 - 18.12.2010
The errors are "invalid function or declaration" and i've listed the affected lines above your post.