Jump to content
  • 0

Creare functie (printfex)


Yonut

Question

Salut, SA-MP.ro!

Am intampinat o problema, doresc sa creez o functie: printfex si am facut cateva incercari si nu mi-a iesit.

Erroare: C:\Users\Yonut\Desktop\Proiect\gamemodes\rpg.pwn(37465) : error 029: invalid expression, assumed zero

stock printfex(const format[], {Float,_}:...)
{
    new hour, minute, second;
    gettime(hour, minute, second);
    printf("[TIME] %d:%d:%d", hour, minute, second);
    printf(format, ...); // linia de la care da error
    return 1;
}

Dau +1 celui care ma ajuta!

Edited by Yonut
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
1 hour ago, WopsS said:

Nu poti sa scrii

format(text, ...);

trebuie sa te folosesti de numargs si getarg. Sincer, nu mai stiu exact cum se facea, dar pe undeva este o varianta de al lui Y_Less mai buna.

O alta varianta foarte buna este sa folosesti y_va.

Iti multumesc! Am folosit y_va din libraria YSI.

 * Script corectat:

stock printfex(const string[], va_args<>)
{
    new hour, minute, second, time[64], strings[256];
    gettime(hour, minute, second);
    format(time, sizeof(time), "[%d:%d:%d]", hour, minute, second);
    format(strings, sizeof(strings), "%s%s", time, string);
    va_printf(strings, va_start<1>);
    return 1;
}

 

  • Upvote 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.