Delayed on storing returned values to variable
#1

So I was planning to create a new include but I have been experiencing issues.

PHP код:
stock CreateGroup(name[], tag[])
{
    
groupID++;
    
GroupInfo[groupID][groupTaken] = true;
    
format(GroupInfo[groupID][groupTag], 5tag);
    
format(GroupInfo[groupID][groupName], 32name);
    return 
groupIDCallLocalFunction("OnCreateGroup""dss"groupIDnametag);

The problem is, there are delays on storing the returned values to the variable and I have tried the technique above and it still didn't work.

What I basically did is

PHP код:
test CreateGroup("Comb""MICA");
test2 CreateGroup("Slut""CLUB");
printf("%d - test variable"test);
printf("%d - test2 variable"test2); 
The test & test2 variable returns 1 and 2 but when you run them up over OnCreateGroup it's 0 and 1

PHP код:
public OnCreateGroup(groupidname[], tag[])
{
    if(
groupid == test)
    {
        print(
"test");
    }
    if(
groupid == test2)
    {
        print(
"slut doval");
    }
    return 
1;

None of those "test" and "slut doval" are printed once the CreateGroup was called.

Any idea on how to solve this out?
Reply
#2

From the code and explanation you provided all I can see is that you are using a variable before it is defined.

pawn Код:
return groupID, CallLocalFunction("OnCreateGroup", "dss", groupID, name, tag);
This will return OnCreateGroup return value, what are you trying to achieve here?
Reply
#3

I am not currently in the best shape to explain it but what I am trying to do is to get the groupID stored up first so that the "test" & "test2" variable won't return 0 & 1, and call OnCreateGroup last but it didn't worked.
Reply
#4

PAWN is single-threaded, you're trying to use the variable before you assign a value to it.

I would use a timer, or:
Код:
new test;
CreateGroup(test, "Comb", "MICA");

stock CreateGroup(&variable, name[], tag[]) 
{
    groupID++;
    variable = groupID;
    GroupInfo[groupID][groupTaken] = true; 
    format(GroupInfo[groupID][groupTag], 5, tag); 
    format(GroupInfo[groupID][groupName], 32, name); 
    CallLocalFunction("OnCreateGroup", "dss", groupID, name, tag); 
    return 1;
}
Reply
#5

Quote:
Originally Posted by Marricio
Посмотреть сообщение
PAWN is single-threaded, you're trying to use the variable before you assign a value to it.

I would use a timer, or:
Код:
new test;
CreateGroup(test, "Comb", "MICA");

stock CreateGroup(&variable, name[], tag[]) 
{
    groupID++;
    variable = groupID;
    GroupInfo[groupID][groupTaken] = true; 
    format(GroupInfo[groupID][groupTag], 5, tag); 
    format(GroupInfo[groupID][groupName], 32, name); 
    CallLocalFunction("OnCreateGroup", "dss", groupID, name, tag); 
    return 1;
}
Didn't thought about that, but it worked thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)