SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/04/2016, 04:07 PM   #1
saket
Little Clucker
 
Join Date: Nov 2012
Posts: 10
Reputation: 0
Question tmp = strtok(text, idx);

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 (c) 1997-2006, ITB CompuPhase


12 Errors.
saket is offline   Reply With Quote
Old 05/04/2016, 04:30 PM   #2
sheNdjze
Big Clucker
 
sheNdjze's Avatar
 
Join Date: Aug 2012
Location: Venezia
Posts: 97
Reputation: 11
Default Re: Help!! tmp = strtok(text, idx);

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
__________________
WWW.REBORNKILLERZ.COM


ReborN RPG Server: RPG.REBORNKILLERZ.COM / 93.119.26.207:7777

(don't PM me for scripting help)

From Romania.
SA-MP Player Since 2006
SA-MP Scripter Since 2014

sheNdjze is offline   Reply With Quote
Old 05/04/2016, 04:37 PM   #3
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,327
Reputation: 681
Default Re: Help!! tmp = strtok(text, idx);

Quote:
Originally Posted by sheNdjze View Post
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: http://forum.sa-mp.com/showthread.php?t=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?
AndySedeyn is offline   Reply With Quote
Old 05/04/2016, 04:41 PM   #4
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 2,012
Reputation: 491
Default Re: Help!! tmp = strtok(text, idx);

is tmp is declared as array show its declaration
SyS is offline   Reply With Quote
Old 05/04/2016, 04:47 PM   #5
sheNdjze
Big Clucker
 
sheNdjze's Avatar
 
Join Date: Aug 2012
Location: Venezia
Posts: 97
Reputation: 11
Default Re: Help!! tmp = strtok(text, idx);

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);
__________________
WWW.REBORNKILLERZ.COM


ReborN RPG Server: RPG.REBORNKILLERZ.COM / 93.119.26.207:7777

(don't PM me for scripting help)

From Romania.
SA-MP Player Since 2006
SA-MP Scripter Since 2014

sheNdjze is offline   Reply With Quote
Old 05/04/2016, 04:51 PM   #6
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 2,012
Reputation: 491
Default Re: Help!! tmp = strtok(text, idx);

Quote:
Originally Posted by sheNdjze View Post
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
SyS is offline   Reply With Quote
Old 05/04/2016, 04:59 PM   #7
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,327
Reputation: 681
Default Re: Help!! tmp = strtok(text, idx);

Quote:
Originally Posted by Sreyas View Post
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
Code:
new name[20 char]
is wrong
It's not wrong.

Quote:
Originally Posted by sheNdjze View Post
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 Code:
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
AndySedeyn is offline   Reply With Quote
Old 05/04/2016, 05:12 PM   #8
Crayder
High-roller
 
Crayder's Avatar
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,863
Reputation: 603
Default Re: Help!! tmp = strtok(text, idx);

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).
__________________
Those who deserve reputation, do not need to beg for it.
Also, don't expect the help you need when offering reputation, you'll just be attracting Rep Hunters.
Join SA-MP Discord!
Crayder is offline   Reply With Quote
Old 06/04/2016, 06:43 AM   #9
saket
Little Clucker
 
Join Date: Nov 2012
Posts: 10
Reputation: 0
Default Re: tmp = strtok(text, idx);

okay i will use sscanf instead of strtok, thx for every reply.
saket is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change format text to 3D text {house System RP} daniel05277 Scripting Help 1 09/09/2015 07:02 AM
[Ajuda] strtok Caio_Freeze PortuguÍs/Portuguese 4 07/08/2014 05:50 AM
strtok JEkvall95 Scripting Help 4 17/10/2012 03:42 PM
Strtok. davelord Help Archive 1 05/08/2011 01:04 PM
Command / text [text / text] [player id / all] MrLeNy Help Archive 6 10/04/2010 10:18 PM


All times are GMT. The time now is 09:59 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.