Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

I need help with enums and textdraws.

$
0
0
I have to textdraws. One arrow pointing left and one pointing right.
I want to make it so when I click right, it will get the next object that fits the criteria from the enum.

This is my current code:

Code:

                if(playertextid == objects_select_left)
                {
                        for(new i = sizeof(sv_objects); i >= 0; i--)
                        {

                                if(sv_objects[i][objID] > 0 && sv_objects[i][objType] == GetPVarInt(playerid, "zip_type") && acc_last_id[playerid] > i)
                                {
                                        PlayerTextDrawSetPreviewModel(playerid, objects_middle_image, sv_objects[i][objModel]);
                                        PlayerTextDrawShow(playerid, objects_middle_image);
                                       
                                        format(string, sizeof(string), "PRICE $%d / %d PP / %d BP", sv_objects[i][objPrice], sv_objects[i][objPP], sv_objects[i][objBP]);
                                        PlayerTextDrawSetString(playerid, objects_show_price, string);

                                        acc_last_id[playerid] = i;
                                }
                        }
                }

                if(playertextid == objects_select_right)
                {
                        for(new i; i < MAX_SV_OBJECTS; i++)
                        {
                                if(sv_objects[i][objID] > 0 && sv_objects[i][objType] == GetPVarInt(playerid, "zip_type") && acc_last_id[playerid] < i)
                                {
                                        PlayerTextDrawSetPreviewModel(playerid, objects_middle_image, sv_objects[i][objModel]), PlayerTextDrawShow(playerid, objects_middle_image);
                                       
                                        format(string, sizeof(string), "PRICE $%d / %d PP / %d BP", sv_objects[i][objPrice], sv_objects[i][objPP], sv_objects[i][objBP]);
                                        PlayerTextDrawSetString(playerid, objects_show_price, string);

                                        acc_last_id[playerid] = i;
                                        break;
                                }
                        }
                }

sv_objects is the enum. The GetPVarInt is the type which in this case doesn't really matter.

I want to make it so when you click the right one, you get the next one from the enum which fits the criteria.
If you press the left one, you get the first one in the opposite direction from the enum.

How can I make it?
When I click the right one, everything works fine. But when I click the left one, it won't go back.

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>