Uncommon problem with an array
#1

SOLVED
Hello community, I'm developing a new filterscript (the second version of Sasinosoft Houses, remade from scratch), but I have a very strange and uncommon issue.

At the beginning I defined:
pawn Code:
#define INVALID_HOUSE_ID -255
new LastHouse[MAX_PLAYERS];
Then under OnPlayerConnect I put:

pawn Code:
public OnPlayerConnect(playerid)
{
    LastHouse[playerid] = INVALID_HOUSE_ID;
        printf("LastHouse(%d) = %d", playerid, LastHouse[playerid]);
    return 1;
}
And the program will print to the console:
Code:
[19:47:10] [join] Sasino97 has joined the server (0:127.0.0.1)
[19:47:13] LastHouse(0) = 0
when it should be -255.... Another strange thing I noticed is that the second line is printed 3 seconds later.

I put the prints after noticing that error in the system.
Reply
#2

Just to debug it:

pawn Code:
#define INVALID_HOUSE_ID -1

//or

#define INVALID_HOUSE_ID 56
Show me the output. I guess MACROS does not support negative numbers bud i dont think so!
Reply
#3

Quote:
Originally Posted by Ballu Miaa
View Post
Just to debug it:

pawn Code:
#define INVALID_HOUSE_ID -1

//or

#define INVALID_HOUSE_ID 56
Show me the output. I guess MACROS does not support negative numbers bud i dont think so!
The same:
pawn Code:
#define INVALID_HOUSE_ID 56
Code:
[20:33:08] [join] Sasino97 has joined the server (0:127.0.0.1)
[20:33:10] LastHouse(0) = 0
EDIT:

It's not a problem with the macro, look:
pawn Code:
public OnPlayerConnect(playerid)
{
    LastHouse[playerid] = 15;
    printf("LastHouse(%d) = %d", playerid, LastHouse[playerid]);
    return 1;
}
will also print 0
Reply
#4

Weird. Look what I got here:
Code:
[22:02:56] Incoming connection: 127.0.0.1:51685
[22:02:57] [join] HellSphinX has joined the server (0:127.0.0.1)
[22:02:57] LastHouse(0) = -255
Reply
#5

Quote:
Originally Posted by HellSphinX
View Post
Weird. Look what I got here:
Code:
[22:02:56] Incoming connection: 127.0.0.1:51685
[22:02:57] [join] HellSphinX has joined the server (0:127.0.0.1)
[22:02:57] LastHouse(0) = -255
Try it on a filterscript please
Reply
#6

It should work same too! Works in mine too bro!
Reply
#7

I've already tried it on a filterscript. A gamemode as well - just the same results.
Reply
#8

I made a blank one for testing this:

pawn Code:
#include <a_samp>
#define DEF 256

new A[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    A[playerid] = DEF;
    printf("CONNECT: A(%d) = %d", playerid, A[playerid]);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    printf("SPAWN: A(%d) = %d", playerid, A[playerid]);
    return 1;
}
Only printed:

Code:
[21:17:35] [join] Sasino97 has joined the server (0:127.0.0.1)
[21:17:37] SPAWN: A(0) = 0
The printf on Connect is completely ignored, it makes me think that OnPlayerConnect isn't called at all...
Reply
#9

Both CONNECT and SPAWN were printed here. And wasn't OnPlayerConnect called on your first try?
Reply
#10

SOLVED https://sampforum.blast.hk/showthread.php?tid=148846&page=2 look at [HLF]Southclaw's post.

Thank you guys for trying to help me, I'll add reputation to you too

There was another filterscript loaded before that didn't return anything on OnPlayerConnect and was blocking all the next FSs
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)