Quote:
Originally Posted by ******
What is it with people recently assuming that people use MySQL - I've seen it in an increasing number of topics. The OP asks a perfectly normal question and doesn't mention MySQL at any point; at no point do they say they have it installed, have it set up or have any interest in using it at all; yet answers start using it.
MySQL, like ALL plugins, is non-standard. If you are going to use it at least mention that "this will require you to install a massive great library designed for huge websites on to your tiny little SA:MP server which already has perfectly good database functionality built in, just for one line of code" (or words to that effect). You cannot assume that people have any plugins installed, even common ones like sscanf should be explicitly stated.
|
Quote:
Originally Posted by ludesert
No. But do you know how to make a command log ?
|
Quote:
Originally Posted by Cameltoe
Yes,
pawn Код:
stock Log(Text[]) { new Query[130]; format(Query, sizeof(Query), "INSERT INTO logs (id, text) VALUES (NULL, '%s');", Text); mysql_query(Query); }
Besides stripping the Text for mysql injections, this is how i would do it.
|
He asked me if i knew how to script and command log, and basicly that's how i would do it, i did not assume Ludesert were using mysql at all.
Anyway, this should work :
pawn Код:
// Zcmd
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
CommandLog(playerid, cmdtext);
return 1;
}
// Strcmp
public OnPlayerCommandText(playerid, cmdtext[])
{
CommandLog(playerid, cmdtext);
return 1;
}
stock CommandLog(playerid, text[])
{
new
File:lFile = fopen("Logs/CommandLog.txt", io_append),
logData[178],
fyear, fmonth, fday,
fhour, fminute, fsecond;
getdate(fyear, fmonth, fday);
gettime(fhour, fminute, fsecond);
format(logData, sizeof(logData),"[%02d/%02d/%04d %02d:%02d:%02d] %s: %s \r\n", fday, fmonth, fyear, fhour, fminute, fsecond, GetName(playerid), text);
fwrite(lFile, logData);
fclose(lFile);
return 1;
}
stock GetName(playerid)
{
new pName[25];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}