SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 13/04/2019, 03:49 PM   #1
ghostbalkan
Little Clucker
 
Join Date: Feb 2017
Posts: 6
Reputation: 0
Default string into array

CODE:
Code:
CMD:vipboja(playerid, const params[])
{
	if(vip_Info[playerid][VIPBodovi] <= 0)
        return SendClientMessage(playerid, vip_Info[playerid][VIPBoja], "VIP | {FFFFFF}Nemate VIP bodova.");

    extract params -> new string:vipboja[11]; else
	{
        return SendClientMessage(playerid, vip_Info[playerid][VIPBoja], "VIP | {FFFFFF}/vipboja (boja - primjer 0x8b9940FF)");
    }

    strins(vipboja, vip_Info[playerid][VIPBodovi], 0);
    vip_Info[playerid][VIPBodovi] --;
    
	format(game_string, sizeof(game_string), "VIP | {FFFFFF}Postavili ste sebi VIP boju  na %s.", vipboja);
	SendClientMessage(playerid, vip_Info[playerid][VIPBoja], game_string);
	game_string[0] = EOS;
	format(game_string, sizeof(game_string), "VIP | {FFFFFF}Trenutni VIP bodovi %i", vip_Info[playerid][VIPBodovi]);
	SendClientMessage(playerid, vip_Info[playerid][VIPBoja], game_string);
	game_string[0] = EOS;
	return true;
}
my brain just blocked lmao
https://imgur.com/BgNfvrP and the string when I print it is that letter y.
ghostbalkan is offline   Reply With Quote
Old 13/04/2019, 04:14 PM   #2
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 635
Reputation: 64
Default Re: string into array

Can you give a detailed explanation of the bug that is occurring to you?

Strings are arrays. Maybe, look into this wiki article about "string into array" https://wiki.alliedmods.net/index.ph...torial#Strings
__________________
coool is offline   Reply With Quote
Old 13/04/2019, 08:31 PM   #3
ghostbalkan
Little Clucker
 
Join Date: Feb 2017
Posts: 6
Reputation: 0
Default Re: string into array

I fixed it on this way
Code:
CMD:vipboja(playerid, const params[])
{
	if(vip_Info[playerid][VIPBodovi] <= 0)
        return SendClientMessage(playerid, vip_Info[playerid][VIPBoja], "VIP | {FFFFFF}Nemate VIP bodova.");

    extract params -> new string:vipboja[11]; else
	{
        return SendClientMessage(playerid, vip_Info[playerid][VIPBoja], "VIP | {FFFFFF}/vipboja (boja - primjer 0x8b9940FF)");
    }

    strcpy(vip_Info[playerid][VIPBoja], vipboja, sizeof(vipboja));
    vip_Info[playerid][VIPBodovi] --;
    
	format(game_string, sizeof(game_string), "VIP | {FFFFFF}Postavili ste sebi VIP boju  na %s.", vipboja);
	SendClientMessage(playerid, vip_Info[playerid][VIPBoja], game_string);
	game_string[0] = EOS;
	format(game_string, sizeof(game_string), "VIP | {FFFFFF}Trenutni VIP bodovi %i", vip_Info[playerid][VIPBodovi]);
	SendClientMessage(playerid, vip_Info[playerid][VIPBoja], game_string);
	game_string[0] = EOS;
	return true;
}
Code:
strcpy(dest[], src[], size = sizeof(dest))
{
    dest[0] = EOS;
    return strcat(dest, src, size);
}

it is working now but color is always black?
I put VIP Color ein enumator and I SendClientMessage like this
Code:
	format(game_string, sizeof(game_string), "VIP | {FFFFFF}Postavili ste sebi VIP boju na %s.", vipboja);
	SendClientMessage(playerid, vip_Info[playerid][VIPBoja], game_string);


I am really confused rn haha
ghostbalkan is offline   Reply With Quote
Old 13/04/2019, 09:01 PM   #4
TokicMajstor
Huge Clucker
 
TokicMajstor's Avatar
 
Join Date: Oct 2018
Location: Bosnia And Herzegovina
Posts: 214
Reputation: 10
Default Re: string into array

Quote:
Originally Posted by ghostbalkan View Post
I fixed it on this way
Code:
CMD:vipboja(playerid, const params[])
{
	if(vip_Info[playerid][VIPBodovi] <= 0)
        return SendClientMessage(playerid, vip_Info[playerid][VIPBoja], "VIP | {FFFFFF}Nemate VIP bodova.");

    extract params -> new string:vipboja[11]; else
	{
        return SendClientMessage(playerid, vip_Info[playerid][VIPBoja], "VIP | {FFFFFF}/vipboja (boja - primjer 0x8b9940FF)");
    }

    strcpy(vip_Info[playerid][VIPBoja], vipboja, sizeof(vipboja));
    vip_Info[playerid][VIPBodovi] --;
    
	format(game_string, sizeof(game_string), "VIP | {FFFFFF}Postavili ste sebi VIP boju  na %s.", vipboja);
	SendClientMessage(playerid, vip_Info[playerid][VIPBoja], game_string);
	game_string[0] = EOS;
	format(game_string, sizeof(game_string), "VIP | {FFFFFF}Trenutni VIP bodovi %i", vip_Info[playerid][VIPBodovi]);
	SendClientMessage(playerid, vip_Info[playerid][VIPBoja], game_string);
	game_string[0] = EOS;
	return true;
}
Code:
strcpy(dest[], src[], size = sizeof(dest))
{
    dest[0] = EOS;
    return strcat(dest, src, size);
}

it is working now but color is always black?
I put VIP Color ein enumator and I SendClientMessage like this
Code:
	format(game_string, sizeof(game_string), "VIP | {FFFFFF}Postavili ste sebi VIP boju na %s.", vipboja);
	SendClientMessage(playerid, vip_Info[playerid][VIPBoja], game_string);


I am really confused rn haha
Aj brate pisi priv, objasnit cu ti.
__________________

My work:
-MapTD - GTA SA Map on a TextDraw

https://forum.sa-mp.com/showthread.php?t=671806
TokicMajstor is offline   Reply With Quote
Old 13/04/2019, 09:48 PM   #5
ghostbalkan
Little Clucker
 
Join Date: Feb 2017
Posts: 6
Reputation: 0
Default Re: string into array

anyone any solution?
ghostbalkan is offline   Reply With Quote
Old 14/04/2019, 02:49 AM   #6
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,939
Reputation: 504
Default Re: string into array

I'm not sure what you trying to achieve.. But my best guess would be
Are you trying to convert hexadecimal value in string to integer?
SyS is offline   Reply With Quote
Old 14/04/2019, 10:44 AM   #7
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,784
Reputation: 621
Default Re: string into array

If you want to extract the color from the string you can use sscanf (using the x specifier for hexadecimal). You can also change your extract line to use hex instead of string (not sure if "hex" is the actual name since I mostly use the sscanf function).
NaS 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 set string to an array without assigning in to an array? bgedition Scripting Help 13 30/04/2015 10:32 PM
Comparing a string to a string in an array? Dokins Scripting Help 13 16/03/2015 05:41 PM
error 006: must be assigned to an array(To array set string) gamelaster Scripting Help 4 02/02/2012 04:25 AM
[Help] Passing a 2d array (a string array) into fwrite? ]SB[Matt Scripting Help 0 15/01/2012 07:15 PM
string array ? fredl Help Archive 4 22/02/2009 03:05 PM


All times are GMT. The time now is 03:28 PM.


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