string not appearing normally?
#1

Hey. I'm trying to set a message to show up to all when a player starts capturing a zone. I'm having troubles displaying a string. I'll demonstrate:

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for (new i=0;i<gCapZones;i++)
    {
    ...
        if(!gCapZone[i][czCapping])
        {
            ...
            gCapZone[i][czCappingTeam]=gPlayerInfo[playerid][pTeam];
            new capstartstring[100];
            format(capstartstring, sizeof(capstartstring), "%s is being captured by %s", gCapZone[i][czName], gCapZone[i][czCappingTeam]);
            SendClientMessageToAll(-1, capstartstring);
        }
        return 1;
    }
    return 1;
}
The output will be for example: "Hospital is being captured by ". So the second string will be blank and that's what is my problem. It should display the team name that is capturing the zone.

Don't mind the dots I just skipped lines that aren't relevant with this case.
If you spot the issue and help me out, I'll be glad and give you rep!
Reply
#2

Bump. Still need help. If you think I haven't provided enough info to solve the issue let me know.
Reply
#3

Try this.

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for (new i=0;i<gCapZones;i++)
    {
    ...
        if(!gCapZone[i][czCapping])
        {
            ...
            format(gCapZone[i][czCappingTeam], 128, "%s", gPlayerInfo[playerid][pTeam]);
            new capstartstring[100];
            format(capstartstring, sizeof(capstartstring), "%s is being captured by %s", gCapZone[i][czName], gCapZone[i][czCappingTeam]);
            SendClientMessageToAll(-1, capstartstring);
        }
        return 1;
    }
    return 1;
}
Reply
#4

Still blank. Also with your method the capturing finished in milliseconds lol. Thanks for trying tho.
Reply
#5

Can you give us the enumator and the array?
Reply
#6

change this:
pawn Код:
gCapZone[i][czCappingTeam]=gPlayerInfo[playerid][pTeam];
to this
pawn Код:
format(gCapZone[i][czCappingTeam], sizeof(gCapZone[i][czCappingTeam]), "%s", gPlayerInfo[playerid][pTeam]);
edit: oh just realised someone already posted this aha, well this definitely seems to be the problem

also make sure capstartstring has it's correct size.
Reply
#7

Quote:
Originally Posted by Capua
Посмотреть сообщение
Still blank. Also with your method the capturing finished in milliseconds lol. Thanks for trying tho.
then at the top of your script where you defined your enums find czCappingTeam and put czCappingTeam[128]
Reply
#8

you are totally doing wrong.
pawn Код:
gCapZone[i][czCappingTeam]
must be an integer variable, or a defined variable in the script, that's why it returns null , let's take an example of the solution:
pawn Код:
#define TEAM_GROVE 0 // we defined an example team.
stock GetTeamName(teamid) // we created a stock for getting a team name.
{
      new tn[30]; // team name string variable, which we're gonna return later.
      switch(teamid)
      {
            case TEAM_GROVE:
            {
                    tn = "Grove Street"; // team name is Grove Streen, the string which is gonna be returned later.
            }
            // Like this
       }
       return tn;
}
Now, let's use this in the script you have:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for (new i=0;i<gCapZones;i++)
    {
    ...
        if(!gCapZone[i][czCapping])
        {
           
            gCapZone[i][czCappingTeam]= gPlayerInfo[playerid][pTeam];
            new capstartstring[100];
            format(capstartstring, sizeof(capstartstring), "%s is being captured by %s", gCapZone[i][czName], GetTeamName(gCapZone[i][czCappingTeam]);
            SendClientMessageToAll(-1, capstartstring);
        }
        return 1;
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
you are totally doing wrong.
pawn Код:
gCapZone[i][czCappingTeam]
must be an integer variable, or a defined variable in the script, that's why it returns null , let's take an example of the solution:
pawn Код:
#define TEAM_GROVE 0 // we defined an example team.
stock GetTeamName(teamid) // we created a stock for getting a team name.
{
      new tn[30]; // team name string variable, which we're gonna return later.
      switch(teamid)
      {
            case TEAM_GROVE:
            {
                    tn = "Grove Street"; // team name is Grove Streen, the string which is gonna be returned later.
            }
            // Like this
       }
       return tn;
}
Now, let's use this in the script you have:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    for (new i=0;i<gCapZones;i++)
    {
    ...
        if(!gCapZone[i][czCapping])
        {
           
            gCapZone[i][czCappingTeam]= gPlayerInfo[playerid][pTeam];
            new capstartstring[100];
            format(capstartstring, sizeof(capstartstring), "%s is being captured by %s", gCapZone[i][czName], GetTeamName(gCapZone[i][czCappingTeam]);
            SendClientMessageToAll(-1, capstartstring);
        }
        return 1;
    }
    return 1;
}
Wow thanks a thousand times! It works perfectly! Thanks again

Rep to all who helped or atleast tried
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)