getarg help
#1

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
?
Reply
#2

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

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?
Reply
#4

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
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)