| GarbageBox |
08-23-2010 07:13 |
Can someone check where is my signatures plugin wrong?
This is my code.
I want to show a player custom signatures.
But when I test it, my say something but is not /signatures and it will show to me Successfully modified signature to X.
When I type something again, it will show me This signatures had already been use and it won`t show what I say.
Can check where is my code wrong?
Code:
#define SzSay [None]
new SzSignatures[128]
new const SzSignaturesDateBase[] = "Signatures.ini"
new SzPlayers[33][32]
new SzNum[33]
new SzLevels[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say", "Say")
register_clcmd("say_team", "Say_Team")
new SzDataDir[64]
get_localinfo("amxx_datadir", SzDataDir, 63)
format(SzSignatures, 127, "%s/%s", SzDataDir, SzSignaturesDateBase)
check_db()
}
public check_db()
{
new SzDataDir[64]
get_datadir(SzDataDir, 63)
format(SzSignatures, sizeof SzSignatures - 1, "%s/%s", SzDataDir, SzSignaturesDateBase)
new file_pointer = fopen(SzSignatures, "r")
if(!file_pointer)
{
server_print("[Signatures] %s does not exist, automatic create", SzSignatures)
write_file(SzSignatures, "")
}
fclose(file_pointer)
}
stock bool:cont_exists(file[], SzName[])
{
new file_pointer = fopen(file, "rt");
new Buffer[256];
while (!feof(file_pointer))
{
fgets(file_pointer, Buffer, 31);
if(containi(Buffer, SzName) != -1)
{
fclose(file_pointer);
return true;
}
}
return false;
}
public Say(id)
{
new chat[192]
read_args(chat, 191)
remove_quotes(chat)
new arg_Say[14]
new name[32], message[256]
get_user_name(id, name, 31)
if(contain(chat, "/signatures"))
{
new SzName[32]
// new SzPlayerCustomSignatures[14]
new Buffer[256]
// read_args(SzSay, 14)
read_argv(1, arg_Say, 14)
new SzDate[128]
get_time("%x", SzDate, sizeof SzDate - 1)
// new len = strlen(SzPlayerCustomSignatures)
new len
get_user_name(id, SzName, 31)
format(Buffer, sizeof Buffer - 1, "^"%s^" ^"%s^"^n", SzName, arg_Say)
if(cont_exists(SzSignatures, SzName))
{
format(message, 255, "[Signatures] This signatures had already been use.");
color_chat(0, id, message)
return 1;
}
if(len > SIGNATURES_MAX_LEN)
{
format(message, 255, "[Signatures] Signatures max length is %d !", SIGNATURES_MAX_LEN);
color_chat(0, id, message)
return 1;
}
format(message, 255, "[Signatures] Successfully modified signature to: ^"%s^"", arg_Say);
color_chat(0, id, message)
new file = fopen(SzSignatures, "at+");
fprintf(file, Buffer);
fclose(file);
return 1;
}
new CsTeams:userteam =cs_get_user_team(id)
if(equal(chat, ""))
return PLUGIN_HANDLED
if(equal(chat, "%"))
return PLUGIN_HANDLED
if(equal(chat, " "))
return PLUGIN_HANDLED
if(get_user_flags(id) & ADMIN_LEVEL_A)
{
SzLevels = "[ADMIN A]"
}
else
if(get_user_flags(id) & ADMIN_LEVEL_B)
{
SzLevels = "[ADMIN B]"
}
else
if(get_user_flags(id) & ADMIN_LEVEL_C)
{
SzLevels = "[ADMIN C]"
}
else
if(get_user_flags(id) & ADMIN_LEVEL_D)
{
SzLevels = "[ADMIN D]"
}
else
{
SzLevels = "[Player]"
}
if (is_user_alive(id))
{
format(message, 255, "^x04%s %s ^x01Score: %d ^x03%s ^x01: %s", SzLevels, arg_Say, SzScores, name, chat)
color_chat(0, id, message)
}
else if (!is_user_alive(id) && userteam != CS_TEAM_SPECTATOR)
{
format(message, 255, "^x01*DEAD* ^x04%s %s ^x01Score: %d ^x03%s ^x01: %s", SzLevels, arg_Say, SzScores, name, chat)
color_chat(0, id, message)
}
else
{
format(message, 255, "^x01*SPEC* ^x04%s %s ^x01Score: %d ^x03%s ^x01: %s", SzLevels, arg_Say, SzScores, name, chat)
color_chat(0, id, message)
}
return PLUGIN_HANDLED
}
|