Need to learn - 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)
+--- Thread: Need to learn (
/showthread.php?tid=359485)
Need to learn -
Gangs_Rocks - 14.07.2012
Okay,I'm working on a counterstrike gamemode with MULTIPLE maps.
Now, what I'm doing is trying to create a UNIT limit for each team
Unit = Players.
Once a player of that team dies = 1 unit goes down for that team.
If the units of a team reach 0, the other team wins by default.
Now I'm really confused, I have no idea how I can give the score to the other team with my code:
pawn Код:
enum TeamInfo
{
Units,
Zones,
Bonus,
};
#define MAX_TEAMS 2
new tInfo[MAX_TEAMS][TeamInfo];
public OnPlayerDeath(playerid, killerid, reason)
{
SaveStats(playerid);
new team = GetPlayerTeam(playerid);
tInfo[team][Units]--;
if(tInfo[team][Units] == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
{
SendClientMessage(i, GREEN, "%s has run out of soldiers! The other team wins by default! ");
}
}
}
return 1;
}
I'd appreciate a 20-30 minutes lesson on this and some doubt clearing OR simply if someone could tell me how to do it.
Re: Need to learn -
Sinner - 14.07.2012
In your case, I'd say you just give score to everyone who is NOT on the team of which the Units has ran out (so let's assume TEAM0 has no more units, TEAM1 would win, correct?).
To do this:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SaveStats(playerid);
new team = GetPlayerTeam(playerid);
tInfo[team][Units]--;
if(tInfo[team][Units] == 0)
{
new opposite_team = !team;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerTeam(i) == opposite_team) {
// Give them score because the other team has no more units
}
}
}
return 1;
}
We assume the team IDs are 0 and 1, otherwise this example will not work;
A better solution would be:
pawn Код:
// Define your teams
#define TEAM1 556415 // Some team IDS
#define TEAM2 156465 // That don't have to be 0 or 1
// Then get the opposite team in the example above using:
new team = GetPlayerTeam(playerid); // Losing team, as seen above
new opposite_team = (team == TEAM1 ? TEAM2 : TEAM1);
Re: Need to learn -
Gangs_Rocks - 14.07.2012
Compiler crash with that code...
Re: Need to learn -
Andi_Evandy - 14.07.2012
like this?
pawn Код:
enum TeamInfo
{
Units,
Zones,
Bonus,
};
#define MAX_TEAMS 2
new tInfo[MAX_TEAMS][TeamInfo];
public OnPlayerDeath(playerid, killerid, reason)
{
SaveStats(playerid);
new team = GetPlayerTeam(playerid);
tInfo[team][Units]--;
if(tInfo[team][Units] == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) SendClientMessage(i, GREEN, "%s has run out of soldiers! The other team wins by default! ");
if(GetPlayerTeam(i) != team) SetPlayerScore(i, GetPlayerScore(i) + 1); //if Player "i" is not in Team "team", then SetPlayerScore... (CMIIW)
}
}
return 1;
}
well, i don't sure if it works or not
Re: Need to learn -
Gangs_Rocks - 14.07.2012
Crashed with BOTH the codes.