Error with format %s, %d, and %f -
EmilLykke - 20.08.2014
pawn Код:
new amessage[256];
format(amessage, sizeof(amessage), "%s has connected to the server! ID: %d IP: %f", name[playerid], playerid, IP);
SendMessageToAdmins(amessage, COLOR_LIGHTRED);
pawn Код:
stock SendMessageToAdmins(message[], color = COLOR_GOLD)
{
foreach(new i : Player)
{
if(PlayerInfo[i][pAdminlevel] > 0)
{
SendClientMessage(i, color, message);
}
}
}
This is one example.. It doesn't work, the %s %d and %f, it's not working probably.
pawn Код:
format(string, sizeof(string), "%s has respawned all unused faction vehicles.");
SendMessageToSameFaction(string, COLOR_GREY, playerid);
pawn Код:
stock SendMessageToSameFaction(message[], color, playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
if(PlayerInfo[i][pFaction] == PlayerInfo[playerid][pFaction])
{
SendClientMessage(i, color, message);
return 1;
}
return 1;
}
pawn Код:
new string[256];
format(string, sizeof(string), "%s %s has respawned all your faction vehicles!", GetAdminRank(playerid), GetNameWithSpace(playerid));
SendMessageToFactionID(factionid, string, COLOR_GREY);
format(string, sizeof(string), "%s %s has respawned all your faction vehicles of Faction ID: %d", GetAdminRank(playerid), GetNameWithSpace(playerid));
SendMessageToAdmins(string, COLOR_GREY);
pawn Код:
stock SendMessageToFactionID(factionid, message[], color)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pFaction] == factionid)
{
SendClientMessage(i, color, message);
}
}
return 1;
}
Re: Error with format %s, %d, and %f -
zT KiNgKoNg - 20.08.2014
Would you like to into more depth with your problem, we're not mind-readers.
Re: Error with format %s, %d, and %f -
Vince - 20.08.2014
IP is a string. Not every sequence of numbers with dots is a float. Second one doesn't even have the variable added to it. Third one I can't tell without seeing the functions.
Re: Error with format %s, %d, and %f -
EmilLykke - 20.08.2014
The messages are not coming up right, it's like: "in Grain connect to the server. ID: 4, IP: 0.000000"
The all end up wrong etc...
Any ideas?
Re: Error with format %s, %d, and %f -
EmilLykke - 20.08.2014
And what about the "connected" part? The whole name doesn't even come up
Re: Error with format %s, %d, and %f -
SnG.Scot_MisCuDI - 20.08.2014
pawn Код:
format(string, sizeof(string), "%s has respawned all unused faction vehicles.",GetNameWithSpace(playerid));
Re: Error with format %s, %d, and %f -
EmilLykke - 20.08.2014
I kind of fixed the issue, but a new issue has come up.
Let's say you have the name: Connor_Adams, it will show or_Adams instead of the full name
Any ideas to this?
Code:
pawn Код:
new amessage[256];
format(amessage, sizeof(amessage), "%s has connected to the server! ID: %d IP: %s", name[playerid], playerid, IP);
SendMessageToAdmins(amessage, COLOR_LIGHTRED);
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));