30.03.2016, 15:22
Hey guys, I added an updates system to my roleplay script which I can add updates and every player can browse them
/addupdate:
/updates:
I wanted to ask, if I can create a code on my GMX stock that when I GMX, the GMX Needed updates are turned to Bug Fixes and the Update updates are turned to Implemented
/addupdate:
PHP код:
CMD:addupdate(playerid, params[])
{
new type;
if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command.");
if(PlayerInfo[playerid][pAdmin] >= 7)
{
if(sscanf(params, "is[128]", type, params))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /addupdate [type] [text]");
SendClientMessage(playerid, COLOR_WHITE, "** [Types]: 1 = Implemented / 2 = BugFix / 3 = Need GMX / 4 = Update");
return 1;
}
if(AntiAdv(playerid, params)) return 1;
if(type < 1 || type > 4) return SendClientMessage(playerid, COLOR_WHITE, "You've entered an inavlid update type.");
if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_WHITE, "Maximum characters limit is 128.");
new File: file = fopen("updates.cfg", io_append), string[128];
if(type == 1)
{
format(string, sizeof(string), "{088A08}[Implemented]{FFFFFF}: %s\r\n", params);
fwrite(file, string);
fclose(file);
}
else if(type == 2)
{
format(string, sizeof(string), "{B40404}[BugFix]{FFFFFF}: %s\r\n", params);
fwrite(file, string);
fclose(file);
}
else if(type == 3)
{
format(string, sizeof(string), "{FFFF00}[GMX Needed]{FFFFFF}: %s\r\n", params);
fwrite(file, string);
fclose(file);
}
else if(type == 4)
{
format(string, sizeof(string), "{DBA901}[Updated]{FFFFFF}: %s\r\n", params);
fwrite(file, string);
fclose(file);
}
format(string, sizeof(string), "Attention: %s has added a new update, check it out using /updates.", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
Log("logs/updates.log", string);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
}
return 1;
}
PHP код:
CMD:updates(playerid, param[])
{
if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command.");
new string[128], File: file = fopen("updates.cfg", io_read), idx=1;
if(PlayerInfo[playerid][pLevel])
{
SendClientMessage(playerid, COLOR_LIME, "______________ American Life Roleplay Updates _____________");
while(fread(file, string))
{
format(string, sizeof(string), "%s", string);
SendClientMessage(playerid, COLOR_WHITE, string);
idx ++;
}
fclose(file);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command.");
}
return 1;
}