string into array
#1

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.
Reply
#2

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
Reply
#3

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
Reply
#4

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.
Reply
#5

anyone any solution?
Reply
#6

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?
Reply
#7

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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)