AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Natives (https://forums.alliedmods.net/showthread.php?t=185313)

Intouchable 05-15-2012 14:29

Natives
 
Rigister like this:
PHP Code:

public plugin_natives()
{
 
register_native("log_kick""native_log_kick"1)
}

public 
native_log_kick(const szLog[], any:...)
{
 new 
szFile[100], iFileHandleszData[20], szMapName[30], szBase[40], szLogEx[150]
 
get_mapname(szMapNamecharsmax(szMapName))
 
get_time("%Y%m%d"szDatacharsmax(szData))
 
get_basedir(szBasecharsmax(szBase))

 
vformat(szLogExcharsmax(szLogEx), szLog2
 
 
format(szFilecharsmax(szFile), "%s/logs/%s"szBaseKICK_LOGS_DIR)
 if(!
dir_exists(szFile)) mkdir(szFile)
 
format(szFilecharsmax(szFile), "%s/Kicks%s.log"szFileszData)
 
 if(
file_exists(szFile))
  
iFileHandle fopen(szFile"at")
 else
  
iFileHandle fopen(szFile"wt")
  
 if(
iFileHandle)
 {
  
get_time("%Y/%m/%d %H:%M:%S"szDatacharsmax(szData))
  
format(szLogExcharsmax(szLogEx), "^n%s: %s"szDataszLogEx)
  
fputs(iFileHandleszLogEx)
 }
 
fclose(iFileHandle)


Using:
PHP Code:

native log_kick(const szLog[], any:..)

log_kick("[KICK] Admininstartor %s <%s> (%s) kick player %s <%s> (%s) už %s!"clANameclAIPclASteamidclPNameclPIPclPSteamidszReason

And to szLog writing emty fields.. Why with the native don't get normal string?

<VeCo> 05-15-2012 14:34

Re: Natives
 
Why don't you use log_to_file?

Intouchable 05-15-2012 14:52

Re: Natives
 
Because i don't need separatelog file every day, opposed total one for all days...

<VeCo> 05-15-2012 15:18

Re: Natives
 
log_to_file saves everything in one file, it doesn't create seperate files for different days.

Intouchable 05-16-2012 10:07

Re: Natives
 
Quote:

Originally Posted by <VeCo> (Post 1709556)
log_to_file saves everything in one file, it doesn't create seperate files for different days.


Sorry, I want to tell you conversely, that i need to log every day separat, opposed total one for all days.

fysiks 05-16-2012 21:23

Re: Natives
 
Quote:

Originally Posted by Intouchable (Post 1709923)
Sorry, I want to tell you conversely, that i need to log every day separat, opposed total one for all days.

Then you just use log_to_file() with a different name every day.

Intouchable 05-18-2012 09:30

Re: Natives
 
Quote:

Originally Posted by fysiks (Post 1710382)
Then you just use log_to_file() with a different name every day.

PHP Code:

 new szFile[100]
 
formatex(szFilecharsmax(szFile), "%s"GetLogFileName("kick"))
 
log_amx("bb:%s"szFile)
log_to_file(szFile"[KICK] ADMININSTRATOR %s <%s> (%s) kicked player %s <%s> (%s) už %s!"clANameclAIPclASteamidclPNameclPIPclPSteamidszReason)

register_native("GetLogFileName""_GetLogFileName")


public 
_GetLogFileName(const szName[])
{
 new 
iSize ArraySize(Logs), szFile[100]
 
 for(new 
0iSizei++)
 {
  
ArrayGetString(LogsiszFilecharsmax(szFile))
  
  if(
strfind(szFileszName) != -1)
   break
 }
 return 
szName


Obtain this:
L 05/17/2012 - 16:13:04: [amx_log_natives.amxx] aa:AdminCommandsLogs/Kicks20120517
L 05/17/2012 - 16:13:04: [admincmd.amxx] bb:8ļ

It's okey working, but when getting file name obtain nonsense...

Exolent[jNr] 05-18-2012 10:21

Re: Natives
 
PHP Code:

 new szFile[100]
 
GetLogFileName("kick"szFilecharsmax(szFile))
 
log_amx("bb:%s"szFile)
log_to_file(szFile"[KICK] ADMININSTRATOR %s <%s> (%s) kicked player %s <%s> (%s) už %s!"clANameclAIPclASteamidclPNameclPIPclPSteamidszReason

PHP Code:

public plugin_natives()
 
register_native("GetLogFileName""_GetLogFileName")

public 
_GetLogFileName(iPlugin iParams)
{
 new 
szName[/* name size */]
 
get_string(1szNamecharsmax(szName))
 
 new 
szFile[100]
 new 
ret fnGetLogFileName(szNameszFilecharsmax(szFile))
 
 
set_string(2szFileret)
 
 return 
ret
}

fnGetLogFileName(const szName[], szOutput[], iOutputLen)
{
 new 
iSize ArraySize(Logs), szFile[100]
 
 for(new 
0iSizei++)
 {
  
ArrayGetString(LogsiszFilecharsmax(szFile))
  
  if(
strfind(szFileszName) != -1)
   return 
copy(szOutputiOutputLenszFile)
 }
 return 
0



Intouchable 05-18-2012 11:31

Re: Natives
 
Quote:

Originally Posted by Exolent[jNr] (Post 1711380)
PHP Code:

 new szFile[100]
 
GetLogFileName("kick"szFilecharsmax(szFile))
 
log_amx("bb:%s"szFile)
log_to_file(szFile"[KICK] ADMININSTRATOR %s <%s> (%s) kicked player %s <%s> (%s) už %s!"clANameclAIPclASteamidclPNameclPIPclPSteamidszReason

PHP Code:

public plugin_natives()
 
register_native("GetLogFileName""_GetLogFileName")

public 
_GetLogFileName(iPlugin iParams)
{
 new 
szName[/* name size */]
 
get_string(1szNamecharsmax(szName))
 
 new 
szFile[100]
 new 
ret fnGetLogFileName(szNameszFilecharsmax(szFile))
 
 
set_string(2szFileret)
 
 return 
ret
}

fnGetLogFileName(const szName[], szOutput[], iOutputLen)
{
 new 
iSize ArraySize(Logs), szFile[100]
 
 for(new 
0iSizei++)
 {
  
ArrayGetString(LogsiszFilecharsmax(szFile))
  
  if(
strfind(szFileszName) != -1)
   return 
copy(szOutputiOutputLenszFile)
 }
 return 
0



Thanks.


All times are GMT -4. The time now is 00:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.