tmp = strtok(text, idx);
#1

I Get Error On These Lines

"x_weapon = strtok(cmdtext, idx);" and

"tmp = strtok(text, idx);"


The Errors Are:

E:\sapter work\gamemodes\larp.pwn(68221) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(74420) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(74657) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(74723) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(74803) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(75015) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(75156) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(75241) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(75321) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(75466) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(75504) : error 047: array sizes do not match, or destination array is too small
E:\sapter work\gamemodes\larp.pwn(75735) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


12 Errors.
Reply
#2

if you could put the full lines i could help you, anyway i make you an example:
new name[32];
GetPlayerName(playerid,name,sizeof(name));
format(name,sizeof(name),"%s opened the door and killed blablablabla",name);

edit 32 with a higher number like 256 if u didn't understeand just put the lines here, or the full command
Reply
#3

Quote:
Originally Posted by sheNdjze
Посмотреть сообщение
if you could put the full lines i could help you, anyway i make you an example:
new name[32];
GetPlayerName(playerid,name,sizeof(name));
format(name,sizeof(name),"%s opened the door and killed blablablabla",name);

edit 32 with a higher number like 256 if u didn't understeand just put the lines here, or the full command
Your reply has nothing to do with OP's problem. And 256 cells for that?! Read this: https://sampforum.blast.hk/showthread.php?tid=580165

OT: Strtok is as outdated as the gamemode you're editing. Download a more updated gamemode and add your own features to it. How is tmp declared?
Reply
#4

is tmp is declared as array show its declaration
Reply
#5

AndySedeyn i've read this topic, its interesting but i still didn't understend, i should use like this?
new name[20 char]; with the chars in the text or? can you explain me better maybe or i'm right? like i got this
new name[20 char];
(blabla, "%s joined the server", name);
Reply
#6

Quote:
Originally Posted by sheNdjze
Посмотреть сообщение
AndySedeyn i've read this topic, its interesting but i still didn't understend, i should use like this?
new name[20 char]; with the chars in the text or? can you explain me better maybe or i'm right? like i got this
new name[20 char];
(blabla, "%s joined the server", name);
your reply and his problem is not connected and using 256 as cell size is like wasting and it makes the compiler slow too a good programmer should know the processing compotent well and should make its working ease
Reply
#7

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
your reply and his problem is not connected and using 256 as cell size is like wasting and it makes the compiler slow too a god programmer should know the processing compotent well and should make its working ease
And
Код:
new name[20 char]
is wrong
It's not wrong.

Quote:
Originally Posted by sheNdjze
Посмотреть сообщение
AndySedeyn i've read this topic, its interesting but i still didn't understend, i should use like this?
new name[20 char]; with the chars in the text or? can you explain me better maybe or i'm right? like i got this
new name[20 char];
(blabla, "%s joined the server", name);
If you want to pack your string, then yes, use char. It's trivial in this case, so you can leave it as it is:
PHP код:
new name[43]; // (20 - 2) for the actual size and 24 for the player's name + \0 
A brief explanation on what packed strings exactly are/do is also in the tutorial:
Quote:
Originally Posted by tutorial
Regular strings store one character per cell and a cell is 4 bytes long (making 256 long strings exactly a kilobyte in size), packed strings store 4 characters per cell
Reply
#8

You are all derailing this thread. Nothing said so far relates to the problem (except AndySedeyn's minor OT note).



ON TOPIC.
strtok - The outdated function that tokenizes (splits) a string into multiple parts in a very inefficient way.
You have multiple problems here: 1, you are attempting to assign a string to a string of a different length; 2, you are using the old LARP mode, which is EXTREMELY outdated; 3, you didn't give us any code to work with; 4, you didn't explain anything, you just gave us the compiler output and left; 5, you are using the outdated methods such as strtok.

Solution: Learn how to script for yourself and learn the latest methods (in this case, get your hands on the sscanf plugin).
Reply
#9

okay i will use sscanf instead of strtok, thx for every reply.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)