strtok problems - 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: strtok problems (
/showthread.php?tid=239924)
strtok problems -
BizzyD - 14.03.2011
Hello, currently i got some troubles with strtok. I am scripting a stunt server. And well, i get this errors.
Код:
error 017: undefined symbol "strtok"
invalid expression, assumed zero
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
This is the line where the errors are on:
pawn Код:
strtok(const string[], &index)
This is my OnGameModeInit code, Where the strtok code is on:
pawn Код:
public OnGameModeInit()
{
new string[MAX_PLAYER_NAME];
SetGameModeText("WW-Stunts Beta");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
{
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
return 1;
}
}
Cant find what the problem is, Anybody knows?
Thanks, Alex
Re: strtok problems -
Kwarde - 14.03.2011
Wrong; AddPlayerClass is a function, not a statement.
strtok shouldn't be placed in a callback. Fixed script:
pawn Код:
public OnGameModeInit()
{
new string[MAX_PLAYER_NAME];
SetGameModeText("WW-Stunts Beta");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
That should be okay
Re: strtok problems -
Stigg - 14.03.2011
EDIT: To late.
Re: strtok problems -
BizzyD - 14.03.2011
Quote:
Originally Posted by Kwarde
Wrong; AddPlayerClass is a function, not a statement.
strtok shouldn't be placed in a callback. Fixed script:
pawn Код:
public OnGameModeInit() { new string[MAX_PLAYER_NAME]; SetGameModeText("WW-Stunts Beta"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; }
strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; }
That should be okay
|
lol fail
Well thanks :P Didnt see that