Quote:
Originally Posted by PartialCloning
How can I pre-format a string like:
HTML Code:
new Format[][]{
"Your steamID is: %s.",
"Your code is: %d.",
"You won 20 tickets for completing the %s task and killing %d players"
};
public TaskHunter(ID, Request)
{
client_print(ID, print_chat, "%s", Format[2], "Hunter", g_MyKill[ID]);
}
Like a language file but embedded within the plugin?
|
I would recommend against that, and instead get those values on the fly.
E.g.
PHP Code:
enum
{
REQUEST_STEAM,
REQUEST_CODE,
REQUEST_TICKET_WIN
}
new g_iCode[MAX_PLAYERS]
new g_iKillCount[MAX_PLAYERS]
new const g_szTask[] = "human killer"
public printPlayerMessage(id, iRequest)
{
switch(iRequest)
{
case REQUEST_STEAM:
{
static szSteamId[32]
get_user_authid(id, szSteamId, charsmax(szSteamId))
client_print(id, print_chat, "Your Steam ID is: %s", szSteamId)
}
case REQUEST_CODE:
{
client_print(id, print_chat, "Your code is: %i", g_iCode[id])
}
case REQUEST_TICKET_WIN:
{
// TODO: 20 tickets should not be hard coded
client_print(id, print_chat, "You have won 20 tickets for completing task %s and killing %i players", g_szTask, g_iKillCount)
}
default:
{
log_amx("printPlayerMessage: Request out of range [%i]", iRequest)
}
}
}
But if you must:
Otherwise you will need to maintain an array of players that contain that information. You could do a 3d string array, e.g. new sGameMessages[MAX_PLAYERS][][] - It should work, but I would not recommend this and instead opt for a dynamic array:
A better way would be to maintain a dynamic array of messages for players; Read about this here:
https://forums.alliedmods.net/showthread.php?t=249602 (Check out Hamlets code example that uses enum _: eData)