09.01.2010, 13:49
Hi guys... I have two dmcd commands, /idea and /ideas.
/idea:
/ideas:
I also have a command that save the text to a file:
( Note: I am not (using/dont have/dont know how to get) this in my gamemode: LAdmin, PlayerInfo, MessageToAdmins. )
My problem is that i want them in "if(strcmp(cmdtext, "/idea", true) == 0)", and "if(strcmp(cmdtext, "/ideas", true) == 0)", but when i try, nothing gets in the file...
I also think this code is too complicated, i mean it is not easy to find out what is what in that code.
So i am requersting some help to make it more simple and maybe if you also could help me to build in a load/save file function.
Thanks for your time to read this, Robin.
P.S. If theres something i havent explained, or theres something you dont understand, then just ask and i will try to explain/use other words...
/idea:
pawn Код:
dcmd_idea(playerid,params[]) {
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /Idea [Your Player ID] [YOUR IDEA]");
if(strlen(params) > 7) {
new ideaer[MAX_PLAYER_NAME], str[128], hour,minute,second; gettime(hour,minute,second);
GetPlayerName(playerid, ideaer, sizeof(ideaer));
format(str, sizeof(str), "|NEWIDEA| %s (%s) |%d:%d:%d|", ideaer,params[strlen(tmp)+1], hour,minute,second);
MessageToAdmins(COLOR_WHITE,str);
SaveToFile("IdeaLog",str);
format(str, sizeof(str), "Idea: %s (%s) |%d:%d:%d|", ideaer,params[strlen(tmp)+1], hour,minute,second);
for(new i = 1; i < MAX_IDEAS-1; i++) Ideas[i] = Ideas[i+1];
Ideas[MAX_IDEAS-1] = str;
return SendClientMessage(playerid,yellow, "Your Idea has been sent to online administrators.");
} else return SendClientMessage(playerid,red,"ERROR: Must be a valid Idea, /Idea [Your Player ID] [YOUR IDEA]");
}
pawn Код:
dcmd_ideas(playerid,params[]) {
#pragma unused params
if(PlayerInfo[playerid][Level] >= 1) {
new IdeaCount;
for(new i = 1; i < MAX_IDEAS; i++)
{
if(strcmp( Ideas[i], "<none>", true) != 0) { IdeaCount++; SendClientMessage(playerid,COLOR_WHITE,Ideas[i]); }
}
if(IdeaCount == 0) SendClientMessage(playerid,COLOR_WHITE,"There have been no Ideas");
} else SendClientMessage(playerid,red,"ERROR: You need to be level 1 to use this command");
return 1;
}
pawn Код:
forward SaveToFile(filename[],text[]);
public SaveToFile(filename[],text[])
{
#if defined SAVE_LOGS
new File:LAdminfile, filepath[256], string[256], year,month,day, hour,minute,second;
getdate(year,month,day); gettime(hour,minute,second);
format(filepath,sizeof(filepath),"ladmin/logs/%s.txt",filename);
LAdminfile = fopen(filepath,io_append);
format(string,sizeof(string),"[%d.%d.%d %d:%d:%d] %s\r\n",day,month,year,hour,minute,second,text);
fwrite(LAdminfile,string);
fclose(LAdminfile);
#endif
return 1;
}
My problem is that i want them in "if(strcmp(cmdtext, "/idea", true) == 0)", and "if(strcmp(cmdtext, "/ideas", true) == 0)", but when i try, nothing gets in the file...
I also think this code is too complicated, i mean it is not easy to find out what is what in that code.
So i am requersting some help to make it more simple and maybe if you also could help me to build in a load/save file function.
Thanks for your time to read this, Robin.
P.S. If theres something i havent explained, or theres something you dont understand, then just ask and i will try to explain/use other words...