/kick help | Not working | need direction -
darkvsoul36 - 23.07.2012
I looked on
https://sampwiki.blast.hk/wiki/Strtok and followed it step by step. Below is what I came up with and under that are the errors I have.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx; //Line 93
cmd = strtok(cmdtext, idx); //Line 94
if(strcmp(cmd, "/kick", true) == 0)
{
new tmp[128];
tmp = strtok(cmdtext, idx); //Line 99
if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid]");
Kick(strval(tmp));
return 1;
}
return 0;
}
Код:
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(94) : error 017: undefined symbol "strtok"
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(94) : error 033: array must be indexed (variable "cmd")
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(99) : error 017: undefined symbol "strtok"
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(99) : error 033: array must be indexed (variable "tmp")
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(93) : warning 203: symbol is never used: "idx"
I am currently unclear at this point and have no idea where to start fixing it. I would like a nudge in the right direction on where to fix this.
NOTE: This is my first command like this so I am pretty much completely lost.
Thanks for the assistance!
Happy Scripting!
EDIT: Bold are lines with errors
Re: /kick help | Not working | need direction -
Akira297 - 23.07.2012
/removed.
Re: /kick help | Not working | need direction -
Kindred - 23.07.2012
Try to add this to your code somewhere:
pawn Код:
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;
}
Not in any funtions, etcetra.
Not certain, as I never use default commands, but that might be needed to do it. It might not be already in the script, as you may need to add it yourself.
Re: /kick help | Not working | need direction -
darkvsoul36 - 23.07.2012
Quote:
Originally Posted by Kindred
Try to add this to your code somewhere:
pawn Код:
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; }
Not in any funtions, etcetra.
Not certain, as I never use default commands, but that might be needed to do it. It might not be already in the script, as you may need to add it yourself.
|
Where would I add this? Under
Re: /kick help | Not working | need direction -
Kindred - 23.07.2012
Considering this is a sort of function, just add it anywhere that is not in a function. I suggest keeping track of where you put your functions, making a seperate area for all your stocks / custom public functions to go.
Re: /kick help | Not working | need direction -
Akira297 - 23.07.2012
Quote:
Originally Posted by darkvsoul36
Where would I add this? Under
|
You add
on the very top of your game-mode or where ever you have your includes listed.
Kindred <3 Keep stealing my posts before I can post the help :P
Thank ya'
Re: /kick help | Not working | need direction -
darkvsoul36 - 23.07.2012
I added what you gave me and I now have 4 errors on line 93.
Line 93:
Код:
strtok(const string[], &index)
Errors:
Код:
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(93) : error 017: undefined symbol "strtok"
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(93) : error 029: invalid expression, assumed zero
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(93) : error 017: undefined symbol "string"
C:\Users\*****\Desktop\GTA Servers\Samp 0.3e server\gamemodes\Test.pwn(93) : fatal error 107: too many error messages on one line