What's wrong [1 line makes OnPlayerText function fail]
#1

I have a problem with a line (new situation[MAX_PLAYERS][256]) which is supposed to store a text per player if needed, see below

Well I've put this in the OnPlayerText func for cellphone system:
pawn Код:
if(Mobile[playerid] != 255)
{
    new idx;
    tmp = strtok(text, idx);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    UnderscoreToSpace( sendername );
    format(string, sizeof(string), "%s (tйlйphone): %s", sendername, text);
    ProxDetector(20.0, playerid, string, color, color, color, color, color);
    new situation[MAX_PLAYERS][256];
    new string2[256];
    //Blabla and then (at a lower level)
         strmid(situation[playerid], text, strlen(text), 256);
    //BLABLA
    return 1;
}
But the problem is that all code after the line "new situation[MAX_PLAYERS][256];" won't load and when I type something in chat box it will well print the string ("%s (tйlйphone) %s") PLUS [playername][text] which is supposed to happen if we only put "return 1" under the OnPlayerText function.

Any help please? Thanks is advance
Reply
#2

It looks like strmid is your problem... I haven't come accross/used it before but having briefly looked it up, it would appear you're saving all the characters after what the player has said....

I'm not entirely sure, but i'd guess strmid was your problem, try using format?

Reply
#3

Quote:
Originally Posted by Coicatak
pawn Код:
if(Mobile[playerid] != 255)
{
    new idx;
    tmp = strtok(text, idx);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    UnderscoreToSpace( sendername );
    format(string, sizeof(string), "%s (tйlйphone): %s", sendername, text);
    ProxDetector(20.0, playerid, string, color, color, color, color, color);
    new situation[MAX_PLAYERS][256];
    new string2[256];
    //Blabla and then (at a lower level)
         strmid(situation[playerid], text, strlen(text), 256);
    //BLABLA
    return 1;
}
strmid(situation[playerid], text, 0, strlen(text), 255);


Reply
#4

Quote:
Originally Posted by Weirdosport
It looks like strmid is your problem... I haven't come accross/used it before but having briefly looked it up, it would appear you're saving all the characters after what the player has said....

I'm not entirely sure, but i'd guess strmid was your problem, try using format?

No it isn't, it's the line "new situation[MAX_PLAYERS][256];" which won't let the code under it load...

Quote:
Originally Posted by MoroJr™
strmid(situation[playerid], text, 0, strlen(text), 255);
Why not 256, because there's 256 slots from 0 but the 256th slot is 255?

EDIT: doesn't work
Reply
#5

new situation[MAX_PLAYERS][256];

Lol, it is 51200 cells, it is not a surprise that do bug your script

You should not ignore what is in compile window.
Reply
#6

POST THE WHOLE "COMMAND" here

Maybe it's not from here
Reply
#7

Quote:
Originally Posted by Nubotron
new situation[MAX_PLAYERS][256];

Lol, it is 51200 cells, it is not a surprise that do bug your script

You should not ignore what is in compile window.
There's no warnings or errors on compilation.

Quote:
Originally Posted by MoroJr™
POST THE WHOLE "COMMAND" here

Maybe it's not from here
it is from here, when I withdraw the line "new situation[MAX_PLAYERS][256]" it works fine
Reply
#8

I talk not about warning or errors but this lined:

Header size: 228 bytes
Code size: 8400 bytes
Data size: 1184 bytes
Stack/heap size: 16384 bytes; estimated max. usage=4257 cells (17028 bytes)
Total requirements: 26196 bytes

If this appear script is bugged.
Reply
#9

It is not a good solotion, it is better to repair the script instead of using dirty work around.
Reply
#10

Quote:
Originally Posted by Nubotron
I talk not about warning or errors but this lined:

Header size: 228 bytes
Code size: 8400 bytes
Data size: 1184 bytes
Stack/heap size: 16384 bytes; estimated max. usage=4257 cells (17028 bytes)
Total requirements: 26196 bytes

If this appear script is bugged.
Why does this mean the script is bugged ? I got this for a long time now, since my pwn file reached a certain size

EDIT: I got this
Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:     6224 bytes
Code size:     599420 bytes
Data size:     1235776 bytes
Stack/heap size:   16384 bytes; estimated max. usage=53010 cells (212040 bytes)
Total requirements: 1857804 bytes
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)