SA-MP Forums Archive
getarg help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: getarg help (/showthread.php?tid=203245)



getarg help - armyoftwo - 26.12.2010

Code:
TestArg(2, 3);
pawn Code:
stock TestArg(...)
{
      printf("%i %i", getarg(0, 0), getarg(1, 0));
}
It only gets numbers.. how can i get strings? ie:

Code:
TestArg("FirstString", "2ndString");
And so it prints: FirstString 2ndString
?


Re: getarg help - DRIFT_HUNTER - 26.12.2010

pawn Code:
%i    (integr)  
%s (Text)
%f (float)
%d (integr)



Re: getarg help - armyoftwo - 26.12.2010

Quote:
Originally Posted by DRIFT_HUNTER
View Post
pawn Code:
%i    (integr)  
%s (Text)
%f (float)
%d (integr)
stock TestArg(...)

I know that, this passes only NUMBERS! hpw can i pass text?


Re: getarg help - RyDeR` - 26.12.2010

pawn Code:
stock TestArg(...)
{
    for(new i; i != numargs(); ++i)
    {
        new
            string[32]
        ;
        for(new x; getarg(i, x) != 0; ++x)
        {
            string[x] = getarg(i, x);
        }
        printf("Arg %d: %s", string);
    }
    return ;
}
pawn Code:
TestArg("FirstString", "2ndString");
will print:
Code:
Arg 0: FirstString
Arg 1: 2ndString



Re: getarg help - armyoftwo - 26.12.2010

Quote:
Originally Posted by RyDeR`
View Post
pawn Code:
stock TestArg(...)
{
    for(new i; i != numargs(); ++i)
    {
        new
            string[32]
        ;
        for(new x; getarg(i, x) != 0; ++x)
        {
            string[x] = getarg(i, x);
        }
        printf("Arg %d: %s", string);
    }
    return ;
}
pawn Code:
TestArg("FirstString", "2ndString");
will print:
Code:
Arg 0: FirstString
Arg 1: 2ndString
Okay thanks