SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Русский/Russian

Reply
 
Thread Tools Display Modes
Old 24/02/2016, 04:13 PM   #1
DeViLsS
Big Clucker
 
Join Date: Oct 2014
Posts: 88
Reputation: 0
Default Кол-во "строк" в массиве

Подскажите пожалуйста. Есть ли способ узнать сколько строк в массиве?
Вот массив:
PHP Code:
new Skins [  ] [  ] = {
    {
12345},
    {
678910111213}
}; 
Вот как узнать, сколько скинов в строке "1"?
PHP Code:
{678910111213
DeViLsS is offline   Reply With Quote
Old 24/02/2016, 05:01 PM   #2
eakwarp
High-roller
 
Join Date: Feb 2007
Posts: 1,912
Reputation: 131
Default Re: Кол-во "строк" в массиве

stock checknuminstr(strid)
{
for(new i; i<16; i++)
{
if(Skins[strid][i]==0)
return i;
}
return -1;
}

Например так.
__________________
More than 10 years of development, more than 40 mb(sic! 1 kk lines+) of source code, more than a two hundred units and more than 35k revisions(upd. aug 2017). Valakas Roleplay - choose your role.

Как правило, то, что делаю я, лишь через годы начинают делать другие, но потом, обязательно мне ставят в укор, "ой, да это уже у всех есть"...



[Gamemode] Valakas Trucker Roleplay (Russian).
eakwarp is offline   Reply With Quote
Old 24/02/2016, 05:15 PM   #3
DeViLsS
Big Clucker
 
Join Date: Oct 2014
Posts: 88
Reputation: 0
Default Re: Кол-во "строк" в массиве

Quote:
Originally Posted by eakwarp View Post
stock checknuminstr(strid)
{
for(new i; i<16; i++)
{
if(Skins[strid][i]==0)
return i;
}
return -1;
}

Например так.
Спасибо.
DeViLsS is offline   Reply With Quote
Old 24/02/2016, 06:13 PM   #4
ZiGGi
Banned
 
Join Date: Sep 2008
Location: Russia
Posts: 1,659
Reputation: 356
Default Re: Кол-во "строк" в массиве

Quote:
Originally Posted by eakwarp View Post
stock checknuminstr(strid)
{
for(new i; i<16; i++)
{
if(Skins[strid][i]==0)
return i;
}
return -1;
}

Например так.
Цикл лучше объявить так:
PHP Code:
for(new isizeof(Skins[]); i++) 
Quote:
Originally Posted by DeViLsS View Post
Подскажите пожалуйста. Есть ли способ узнать сколько строк в массиве?
Вот массив:
PHP Code:
new Skins [  ] [  ] = {
    {
12345},
    {
678910111213}
}; 
PHP Code:
printf("%d"sizeof(Skins)); 
ZiGGi is offline   Reply With Quote
Old 24/02/2016, 06:37 PM   #5
OKStyle
High-roller
 
OKStyle's Avatar
 
Join Date: May 2008
Location: Russia, Orenburg Money: GTA$ 999,999,999
Posts: 3,138
Reputation: 147
Default Re: Кол-во "строк" в массиве

Проще уравнивать кол-во скинов в каждой строке, забивая нулями свободные слоты. Так и проверять удобнее.
__________________
O.K.Style™ Laboratory
Kalcor: "... it's makes the game look like it's not GTA. This mod is called San Andreas Multiplayer. It's not a custom game engine which you can script..."
OKStyle is offline   Reply With Quote
Old 24/02/2016, 07:10 PM   #6
stabker
High-roller
 
Join Date: Mar 2012
Posts: 1,311
Reputation: 86
Default Re: Кол-во "строк" в массиве

В первую ячейку можно записывать количество.
stabker 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
error: undefine symbol "j" and expected token ";" but found "]" JEkvall95 Scripting Help 9 27/07/2013 10:09 AM
5 Dialog errors - Input line too long, undefined symbol "t","is" and "only" Deal-or-die Scripting Help 6 01/05/2012 12:08 PM
Admin script requires "ReturnUser", "strtok" and "IsNumeric" Rubennnnn Help Archive 1 02/12/2009 06:08 PM
"Bots", "AI", "NPCs"... Computer-controlled pedestrians and traffic! ssflsnoob General 2 23/11/2008 06:06 PM


All times are GMT. The time now is 08:11 AM.


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