How i can do something like this...
#1

pawn Код:
stock MoneyActionLog(const logString[256], {Float,_}:...)
I wanna make this function is working like:

pawn Код:
native format(output[], len, const format[], {Float,_}:...);
How i can do that? I want that is my code when i send to console looks like:

pawn Код:
MoneyActionLog("Player %s has $%d", PlayerName(playerid), money);
I don't wanna use the MACRO's for this!

Sorry for my bad english...
Reply
#2

for the money

pawn Код:
new Float:money;
GetPlayerMoney(theplayertoknowthemoney, money);
MoneyActionLog("Player %s has $%d", PlayerName(playerid), money);
Reply
#3

@timaoux
The problem is my string is not formatted when i use this, console shows me:

Код:
Player %s has $%d
And i wanna repair this, but how?
Reply
#4

pawn Код:
new money = GetPlayerMoney(playerid), PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
MoneyActionLog("Player %s has $%d", PlayerName, money);
Reply
#5

Omg, i know how using the format. I wanna make the same working function like format(...), but i have this function and that is no working...
Reply
#6

search for SendClientMessageEx learn the code from glibrary
Reply
#7

You can do it with defines

pawn Код:
#define MoneyActionLog(%0,%1,%2); \
new text[128]; \
format(text,sizeof(text),%0,%1,%2); \
new File:example = fopen("log.txt", io_write); \
fwrite(example, text); \
fclose(example);
Or you could do it with getarg() and numargs()
Here's a tutorial for that
https://sampforum.blast.hk/showthread.php?tid=77000
Reply
#8

Ouch, thanks ******, thats is very good. Reput for you and dice7, thx all.
Reply
#9

Ok, so i use that like this:

pawn Код:
stock MoneyActionLog(logString[256], va_args<>)
{
    new entry[256], hour, minute, second;

    gettime(hour, minute, second);

    va_format(entry, sizeof(entry), logString, va_start<1>);
    format(entry, sizeof(entry), "[%02d:%02d:%02d] %s\n", hour, minute, second, entry);

    new File:hFile = fopen("Logs/money_log.txt", io_append);

    fwrite(File:hFile, entry);

    fclose(File:hFile);
}
And my gamemode is not compiling and has a 0 kb. Whats wrong?
Reply
#10

Hm, i don't have that include, lol. Where i can find that?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)