Raised This Month: $51 Target: $400
 12% 

Solved array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 02-01-2018 , 08:05   array
Reply With Quote #1

PHP Code:
new const array[][] =
{
{
1241,2414,3744},
{
1654,2754,3534}
}; 
how to print this value ?
Thanks

Last edited by indraraj striker; 02-02-2018 at 11:06.
indraraj striker is offline
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 02-01-2018 , 08:23   Re: array
Reply With Quote #2

client_print(id, print_chat, const array)

[HINDI]
aise ho sakta kya ??
[ENG]
Is this possible ??
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 02-01-2018 , 08:31   Re: array
Reply With Quote #3

soumyadip77
[English]
bro , its a multi-dimensional array.
[Hindi]
bhai variable and constant nahi read ker raha hu

Last edited by indraraj striker; 02-01-2018 at 08:33.
indraraj striker is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-01-2018 , 08:50   Re: array
Reply With Quote #4

server_print("%d %d %d", array[0][0], array[0][1], array[0][2])
server_print("%d %d %d", array[1][0], array[1][1], array[1][2])

Output

1241 2414 3744
1654 2754 3534
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 02-01-2018 , 12:18   Re: array
Reply With Quote #5

Hi Natsheh,
Thanks for reply.
PHP Code:
new const array[][] =
{
{
1241,2414,3744},
{
1654,2754,3534}
}; 
how can i choose random from these in one print
Like this
client_print(id,print_chat, "%d %d %d",array[random][0],array[random][1],array[random][2])
indraraj striker is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 02-01-2018 , 12:41   Re: array
Reply With Quote #6

Code:
client_print(id, print_chat, "%i", array[random(sizeof(array)-1)][random(sizeof(array[])-1)]
i`m on the phone, so some brackets might be missing
__________________
retired chump

Last edited by DjSoftero; 02-01-2018 at 12:43.
DjSoftero is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-01-2018 , 13:31   Re: array
Reply With Quote #7

Why the -1?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 02-01-2018 , 13:45   Re: array
Reply With Quote #8

Quote:
Originally Posted by OciXCrom View Post
Why the -1?
lets say we have array[2], sizeof(array) would return 2, right? Then if the random(2) generates 2, you`re crashing. arrays start from 0.
__________________
retired chump

Last edited by DjSoftero; 02-01-2018 at 13:47.
DjSoftero is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-01-2018 , 14:02   Re: array
Reply With Quote #9

Quote:
Originally Posted by DjSoftero View Post
lets say we have array[2], sizeof(array) would return 2, right? Then if the random(2) generates 2, you`re crashing. arrays start from 0.
try to test this random(1) it will always return 0...


here is the source code of random() native...

Code:
static cell AMX_NATIVE_CALL core_random(AMX *amx,cell *params)
{
    unsigned long lo, hi, ll, lh, hh, hl;
    unsigned long result;

    /* one-time initialization (or, mostly one-time) */
    #if !defined SN_TARGET_PS2 && !defined _WIN32_WCE
        if (IL_StandardRandom_seed == INITIAL_SEED)
            IL_StandardRandom_seed=(unsigned long)time(NULL);
    #endif

    lo = IL_StandardRandom_seed & 0xffff;
    hi = IL_StandardRandom_seed >> 16;
    IL_StandardRandom_seed = IL_StandardRandom_seed * IL_RMULT + 12345;
    ll = lo * (IL_RMULT  & 0xffff);
    lh = lo * (IL_RMULT >> 16    );
    hl = hi * (IL_RMULT  & 0xffff);
    hh = hi * (IL_RMULT >> 16    );
    result = ((ll + 12345) >> 16) + lh + hl + (hh << 16);
    result &= ~LONG_MIN;        /* remove sign bit */
    if (params[1]!=0)
        result %= params[1];
    return (cell)result;
}
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-01-2018 at 14:21.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
E1_531G
Senior Member
Join Date: Dec 2017
Old 02-01-2018 , 17:16   Re: array
Reply With Quote #10

Quote:
Originally Posted by DjSoftero View Post
lets say we have array[2], sizeof(array) would return 2, right? Then if the random(2) generates 2, you`re crashing. arrays start from 0.
random(2) will generate only 0 and 1.
__________________
My English is A0
E1_531G is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 01:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode