PHP- Kodu:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Ozel Mesaj TXT"
#define VERSION "1.0"
#define AUTHOR "akcaliberkk"
#define TASK_HUD 8765
new file[] = "addons/amxmodx/configs/mesajlar.txt";
new bool:gChecked[33];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /mesajlarim","ShowMessage");
}
public ShowMessage(id) {
gChecked[id] = true;
new message[200],bool:newmessage;
new bool:has = has_user_message(id,message,charsmax(message),newmessage);
if(!has) {
ColorChat(id,"^3[Ozel Mesaj] ^4Ozel mesajiniz bulunmamaktadir.");
return PLUGIN_HANDLED
}
if(!newmessage) {
ColorChat(id,"^3[Ozel Mesaj] ^4Bir okunmus mesaj bulundu:");
ColorChat(id,"^3*** ^4%s",message);
return PLUGIN_HANDLED
}
ColorChat(id,"^3[Ozel Mesaj] ^4Bir okunmamis mesaj bulundu:");
ColorChat(id,"^3*** ^4%s",message);
set_read(id);
return PLUGIN_HANDLED
}
public client_putinserver(id) {
gChecked[id] = false;
new message[200], bool:newmessage;
if(has_user_message(id,message,charsmax(message),newmessage)) {
if(newmessage) {
set_task(5.0,"ShowHud",id+TASK_HUD);
}
}
}
public ShowHud(id) {
id-=TASK_HUD;
if(!is_user_connected(id)) return PLUGIN_HANDLED
set_hudmessage(0, 255, 42, -1.0, -1.0, 0, 1.0, 1.0)
show_hudmessage(id, "Adiniza Kayitli^n Okunmamis Ozel Mesajiniz Bulunuyor^nKontrol Etmek Icin:^n^n/mesajlarim Yaziniz.")
if(!gChecked[id]) set_task(1.0,"ShowHud",id+TASK_HUD);
return PLUGIN_HANDLED
}
stock set_read(id) {
new f =fopen(file,"a+");
new tempfile[] = "addons/amxmodx/configs/a123temp.txt";
new tf = fopen(tempfile,"a+");
new name[32];
get_user_name(id,name,31);
new buffer[256];
new szName[32], szMessage[200], szCheck[6];
while(fgets(f,buffer,charsmax(buffer))) {
parse(buffer,szName,charsmax(szName),szMessage,charsmax(szMessage),szCheck,charsmax(szCheck));
if(!equali(szName,name)) {
fprintf(tf,"%s",buffer);
} else {
fprintf(tf,"^"%s^" ^"%s^" ^"1^"^n",szName,szMessage)
}
}
fclose(f)
fclose(tf)
delete_file(file);
rename_file(tempfile,file,1);
}
stock bool:has_user_message(id, message[],msglen, &bool:newmessage) {
new f = fopen(file,"rt");
new name[32];
get_user_name(id,name,31);
newmessage = false;
new buffer[256];
new szName[32], szMessage[200], szCheck[6];
new check;
while(fgets(f,buffer,charsmax(buffer))) {
parse(buffer,szName,charsmax(szName),szMessage,charsmax(szMessage),szCheck,charsmax(szCheck))
check = str_to_num(szCheck);
if(equali(szName,name)) {
if(!check) newmessage = true;
copy(message,msglen,szMessage);
fclose(f);
return true;
}
}
fclose(f);
return false;
}
stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...) {
new msg[191], players[32], count = 1;
static len;
len = formatex(msg, charsmax(msg), "^x01" );
vformat(msg[len], charsmax(msg) - len, string, 3);
if(id)players[0] = id;
else get_players(players,count,"ch");
for (new i = 0; i < count; i++){
if(is_user_connected(players[i])){
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
return;
}
configs klasörüne mesajlar.txt dosyasını oluşturun.