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

Solved [Help] sizeof Array (iOrigins)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 10-04-2018 , 12:32   [Help] sizeof Array (iOrigins)
Reply With Quote #1

Hi
I'm looking for a way to use coordinates in an array :
What I try :
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
/*

new const iOrigins[][] = 
{
    "160 208 -1392",
    "-544 208 -1392",
    "-465 1120 -1392",
    "81 1120 -1392",
    "0 -1584 -1560",
    "-2 -2240 -1744",
    "2 -356 -1540"
}*/
new const iX[][] = { "160""-544""-465""81""0""-2""2" }
new const 
iY[][] = { "208""208""1120""1120""-1584""-2240""-356" 
new const 
iZ[][] = { "-1392""-1392""-1392""-1392""-1560""-1744""-1540" 

new 
zero 0

public plugin_init() 
    
set_task(5.0"create_light")

public 
create_light()
{
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(TE_DLIGHT);
// here i try two ways !
    
for(new i=0;i<sizeof(iX);i++)
    {
        
write_coord(iX[i]);
    }
    
write_coord(iY[zero++ % sizeof(iY)]);
    
write_coord(iZ[zero++ % sizeof(iZ)]);
    
write_byte(30);  //radiis
    
write_byte(255);//r
    
write_byte(0);  //g
    
write_byte(0);  //b
    
write_byte(15); // life 
    
write_byte(20); // decay rate
    
message_end();
    
    
set_task(1.0"creat_light")

But I know that the method is not correct. Can I find out how this is done?
__________________

Last edited by abdobiskra; 10-12-2018 at 09:39.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-04-2018 , 12:46   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #2

Save them as float/int, no reason to use strings.
__________________
HamletEagle is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 10-04-2018 , 14:34   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #3

The reason for this is that I have a lot of coordinates
This is just a sample.
PHP Code:
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(TE_DLIGHT);
    
write_coord(160);
    
write_coord(208);
    
write_coord(-1392);
    
write_byte(20);  //radiis
    
write_byte(255);//r
    
write_byte(0);  //g
    
write_byte(0);  //b
    
write_byte(15); // life 
    
write_byte(18); // decay rate 20
    
message_end();
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(TE_DLIGHT);
    
write_coord(-544);
    
write_coord(208);
    
write_coord(-1392);
    
write_byte(20);
    
write_byte(255);
    
write_byte(0);
    
write_byte(0);
    
write_byte(15);
    
write_byte(18);
    
message_end();
....
....
etc 
That's a lot!
__________________

Last edited by abdobiskra; 10-04-2018 at 14:35.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-04-2018 , 17:34   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #4

What HamletEagle said still applies. You would access the specific origin with the first dimension, and the individual values with the second.

Variable[ Which Item ][ Sub-value ]

PHP Code:
new Float:fOrigins[][] = 
{
    { 
111.0 222.0 333.0 },
    { 
444.0 555.0 666.0 },
    { 
777.0 888.0 999.0 }
};

server_print"Origin = %f %f %f" fOrigins][ ] , fOrigins][ ] , fOrigins][ ] ); 
PHP Code:
new RGBColors[][] = 
{
    { 
111 222 123 },
    { 
25 55 },
    { 
}
};

server_print"Color = %d %d %d" RGBColors][ ] , RGBColors][ ] , RGBColors][ ] ); 
__________________

Last edited by Bugsy; 10-04-2018 at 17:37.
Bugsy is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 10-05-2018 , 03:55   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #5

and To call her ?
PHP Code:
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(TE_DLIGHT);
    for(new 
i=0;i<sizeof(iX);i++)
    {
        for(new 
t=0;t<sizeof(iX);t++)
        {
            
write_coord(iX[i][t]);
        }
    } 
That's what I really want to understand.
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-05-2018 , 06:05   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #6

sizeof(iX) will give you the number of origins in the array, here you only care about x,y,z for the one origin. Use sizeof(iX[])
__________________

Last edited by Bugsy; 10-05-2018 at 06:09.
Bugsy is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 10-05-2018 , 06:41   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #7

ok
Quote:
warning 224: indeterminate array size in "sizeof" expression (symbol "")
line:
Quote:
for(new i=0;i<sizeof(iX[]);i++)
btw : the server droped me when i used it!
PHP Code:
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(TE_DLIGHT);
    for(new 
i=0;i<sizeof(iX[]);i++)
    {
        
//write_coord(iX[i]);
        
for(new t=0;t<sizeof(iX[]);t++)
        {
            
write_coord(iX[i][t]);
        }
    } 
__________________

Last edited by abdobiskra; 10-05-2018 at 07:19.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 10-05-2018 , 12:47   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #8

Quote:
Originally Posted by abdobiskra View Post
ok

line:


btw : the server droped me when i used it!
PHP Code:
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(TE_DLIGHT);
    for(new 
i=0;i<sizeof(iX[]);i++)
    {
        
//write_coord(iX[i]);
        
for(new t=0;t<sizeof(iX[]);t++)
        {
            
write_coord(iX[i][t]);
        }
    } 
sizeof(iX) instead of sizeof(iX[])
__________________

Last edited by edon1337; 10-05-2018 at 12:47.
edon1337 is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 10-05-2018 , 14:19   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #9

@edon1337
Yes, I tried it but it failed ^^
Quote:
Originally Posted by Bugsy View Post
sizeof(iX) will give you the number of origins in the array, here you only care about x,y,z for the one origin. Use sizeof(iX[])
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-05-2018 , 15:01   Re: [Help] sizeof Array (iOrigins)
Reply With Quote #10

Code:
new const iX[] = { 160, -544, -465, 81, 0, -2, 2 } new const iY[] = { 208, 208, 1120, 1120, -1584, -2240, -356 } new const iZ[] = { -1392, -1392, -1392, -1392, -1560, -1744, -1540 }

sizeof iX not sizeof(iX)

Quote:
for(new i=0;i<sizeof(iX);i++)
{
write_coord(iX[i]);
}

write_coord(iY[zero++ % sizeof(iY)]);
write_coord(iZ[zero++ % sizeof(iZ)]);
This doesn't make any sense to me. You're going to crash your server at this point. If you want to set a random x axis, iX[random(sizeof iX)), otherwise, I didn't got what you're trying to do.
__________________









Last edited by CrazY.; 10-05-2018 at 15:18.
CrazY. 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 16:12.


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