SA-MP Forums [HELP]Problem with floating point arrays
 New Account Members List Search Today's Posts Mark Forums Read

 24/06/2019, 09:22 PM #1 Gendy Little Clucker   Join Date: May 2014 Posts: 2 Reputation: 0 [HELP]Problem with floating point arrays So im doing this basic business system and im having a hard time with floating points. Code: ```new Float:bizlist[50][4]; // First cell for all businesses, second for (Biz type, x coordinate, y coordinate, z coordinate) // CMD:createbiz(playerid, params[]) { new bizid; new message[128]; new Float:xax, Float:yax, Float:zax; GetPlayerPos(playerid, xax, yax, zax); if(!sscanf(params, "f", bizid)) { for(new i = 0; i < 50; i++) { if((bizlist[i][1] == 0) && (bizlist[i][2] == 0) && (bizlist[i][3] == 0)) { bizlist[i][1] = xax; bizlist[i][2] = yax; bizlist[i][3] = zax; bizlist[i][0] = bizid; format(message,sizeof(message), "Business of type %f has been created succesfully at coordinates X:%f Y:%f Z:%f",bizid, xax, yax, zax); SendClientMessage(playerid, 0x07fc51FF, message); if(bizid == 0) { SetPlayerMapIcon(playerid, i, xax, yax, zax, 6, -1, MAPICON_GLOBAL); } else if(bizid == 1) { SetPlayerMapIcon(playerid, i, xax, yax, zax, 45, -1, MAPICON_GLOBAL); } else if(bizid == 2) { SetPlayerMapIcon(playerid, i, xax, yax, zax, 48, -1, MAPICON_GLOBAL); } break; } if(i > 49) { SendClientMessage(playerid, 0xff0000FF, "All business slots are full"); } } } else { SendClientMessage(playerid, 0x999999FF, "/createbiz (0-Ammu , 1-Clothes, 2-Stripclub)"); } return 1; }``` This line, it doesn't store the entered bizid from the user to store it in the bizlist array, but instead it stores instead a weird floating point number. (I knew this since I made a /showallbiz command that displays business id and type.) Code: `bizlist[i][0] = bizid;`
 24/06/2019, 11:02 PM #2 Plastikmensch Huge Clucker   Join Date: Aug 2016 Posts: 240 Reputation: 13 Re: [HELP]Problem with floating point arrays You are working with different types. If you want to store different types inside an array use an enum. Code: ```enum e_bizlist { bType, //integer Float:bX, //Float Float:bY, Float:bZ } new bizlist[50][e_bizlist];``` And use "d" as specifier in sscanf for bizid
25/06/2019, 04:05 PM   #3
Gendy
Little Clucker

Join Date: May 2014
Posts: 2
Reputation: 0
Re: [HELP]Problem with floating point arrays

Quote:
 Originally Posted by Plastikmensch You are working with different types. If you want to store different types inside an array use an enum. Code: ```enum e_bizlist { bType, //integer Float:bX, //Float Float:bY, Float:bZ } new bizlist[50][e_bizlist];``` And use "d" as specifier in sscanf for bizid
Thanks, I used enum and now it works.

 Thread Tools Display Modes Linear Mode

 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 Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post ilijap Scripting Help 1 07/09/2017 07:45 PM Equuuuin0X Scripting Help 17 01/03/2014 11:06 PM Shoulen Scripting Help 3 14/04/2013 05:37 PM Klid Client Support 2 22/11/2009 10:55 AM lucky32 Client Support 23 15/02/2009 07:52 PM

All times are GMT. The time now is 05:34 PM.

 -- (EN) English -- (RU) Русски Contact Us - SA-MP - Archive - Top