04.11.2012, 15:33
Hi, I'm a newbie scripter and I have a question.
How can I know what value to put inside the [] in the "new Reason" array?
How can I know what value to put inside the [] in the "new Reason" array?
PHP код:
COMMAND:report(playerid,params[])
{
new Target;
new Reason[];//How can I know what value to put inside []?
if(!sscanf(params, "us[32]",Target, Reason))
{
if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!"); //comment this line if you want to try this cmd on yourself
if(!IsPlayerConnected(Target)) //if the ID is invalid
return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!"); //send the player a message, that the ID doesn't exist
new tname[MAX_PLAYER_NAME]; //the name of player one (reporting)
new pname[MAX_PLAYER_NAME]; //the name of player two (the reported)
GetPlayerName(Target,tname,sizeof(tname)); //get (receive) the player's name for the first
GetPlayerName(playerid,pname,sizeof(pname)); //get (receive) the player's name for the second
new rstring[256]; //the report-string
format(rstring,sizeof(rstring),"* Player %s(%d) reported %s(%d)! (Reason: %s)", pname,playerid,tname,Target,Reason); //only admins will receive this message! a specific player with a reason got reported, here we'll use all variables created
SendMessageToAdmins(COLOR_WHITE,rstring); //we'll talk about that later
//NOW HERE, we'll open the reportpath and WRITE into it
new File:Log = fopen(reportPATH, io_append); //here you're opening the path defined
new logData[128]; //create the logdata we wanna write in
new name[MAX_PLAYER_NAME]; //define the name again
GetPlayerName(Target,name,sizeof(name)); //receive the name again
new fTime[6]; //create the specific time for the report
getdate(fTime[0], fTime[1], fTime[2]); //get the report's date
gettime(fTime[3], fTime[4], fTime[5]); //get the report's time
format(logData, sizeof logData, "[%02d/%02d/%04d || %02d:%02d:%02d]%s got reported by %s! (Reason: %s)\r\n", fTime[2], fTime[1], fTime[0], fTime[3], fTime[4], fTime[5], tname, pname, Reason); //this will write everything (name,reason,time,date etc.) into the logdata
fwrite(Log, logData); //write it into the path
fclose(Log); //close the log, finished!
}
else return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /report <playerid> <reason>"); //detects the wrong params from sscanf and send the client this message
return 1;
}