Random war script
#1

pawn Код:
forward RandomWar();
public RandomWar()
{
    new string[128], team1, team2, team3;
   
    new RandomTeams[][] =
    {
        {T_ENGLAND},
        {T_RUSSIA},
        {T_IRAQ},
        {T_MEXICO}
    };
   
    team1 = random(sizeof(RandomTeams));
    team2 = random(sizeof(RandomTeams));
    team3 = random(sizeof(RandomTeams));
   
    if(team1 == team2) team1 = team3;
    if(team2 == team1 && team1 != team3) team2 = team3;
   
    format(string, sizeof string, "A random war has started between team %s and %s!", TeamName(team1), TeamName(team2));
    SendClientMessageToAll(C_WHITE, string);

}
The stock:
pawn Код:
stock TeamName(teamid)
{
    new team[32];
    if(teamid == T_ENGLAND) team = ("England");
    if(teamid == T_RUSSIA) team = ("Russia");
    if(teamid == T_IRAQ) team = ("Iraq");
    if(teamid == T_MEXICO) team = ("Mexico");
    return team;
}
And in game it prints:
pawn Код:
A random war has started between team  and !
Reply
#2

try this
pawn Код:
if(team1 == team2) team1 = team3;
    if(team2 == team1 && team1 != team3) team2 = team3;
   
    format(string, sizeof string, "A random war has started between team %d and %d!", TeamName(team1), TeamName(team2));
    SendClientMessageToAll(C_WHITE, string);

}
Reply
#3

It prints the teams' names fine for me and by the way, you don't need a 2D array.

@iThePunisher: It returns an array/string, not an integer so the placeholder you used is wrong.
Reply
#4

not work, help please!
Reply
#5

Now i have this error
warning 204: symbol is assigned a value that is never used: "RandomTeams"
Reply
#6

help
Reply
#7

please
Reply
#8

Bumping thread everytime will not help you. It will only give you a free infraction.

Try this?

pawn Код:
stock TeamName(teamid)
{
    new team[32];
    switch(teamid)
    {
        case T_ENGLAND: format(team, sizeof(team), "England");
        case T_RUSSIA: format(team, sizeof(team), "Russia");
        case T_IRAQ: format(team, sizeof(team), "Iraq");
        case T_MEXICO: format(team, sizeof(team), "Mexico");
    }
    return team;
}
Reply
#9

Quote:
Originally Posted by Recko
Посмотреть сообщение
Now i have this error
warning 204: symbol is assigned a value that is never used: "RandomTeams"
ignore that warning
The warning means that a symbol is there which is never used
for example i do a=5; and not use 'a' anywhere in the program so i will get this warning that 'a' is never used
Reply
#10

thanks but still the same problem in game with
A random war has started between team and !


iZn your code don't work
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)