[Include] Modshop car color selection menu (SA original)
#1

Tuningshop car color menu




Thanks to AIped for updating the code to support the colors that were added in 0.3x
I've spent some time and remade the car color selection menu used in the modshops all around San Andreas. It is at the exact same position and the colors/cursor also have the exact same size. All colours are exactly the ones used in the original modshops menu.

You are free to use this include however you want. You can modify it, extend it and take snippets out of it. But if you release something which uses this menu, remember to include/keep the credits

The menu uses player textdraws.

Functions

pawn Код:
CreateColorSelectionDialog(playerid);
Used to create the textdraws for the player. Function to be used under OnPlayerConnect()


pawn Код:
DestroyColorSelectionDialog(playerid);
Used to destroy the textdraws for the player (if needed).


pawn Код:
ShowPlayerColorSelectDialog(playerid);
HidePlayerColorSelectDialog(playerid);
Self explanatory. Used to show or hide the menu for the player.

pawn Код:
MoveColorDialogCursor(playerid, direction);
Used to move the cursor (white frame behind the colors).
Possible directions:
pawn Код:
CURSOR_MOVE_UP
CURSOR_MOVE_DOWN
CURSOR_MOVE_LEFT   
CURSOR_MOVE_RIGHT
If the cursor is at the very right of the menu and it is moved right again, it goes down one row and starts over at the very left. Same when moving left but vice versa.


pawn Код:
SelectCurrentColor(playerid);
Used to select the color the cursor (frame) is currently highlighting. Using this function calls OnPlayerSelectColor() (look down for more info on this).


pawn Код:
GetColorFromPosition(column, row);
Gets the vehicle color ID a color is representing by entering the column and row number of the desired color (each number ranging 0-7: 8 rows/columns).



Callbacks

pawn Код:
OnPlayerChangeSelectedColor(playerid, column, row)
Called when the cursor is moved to a new color. Row/column represent the new position the cursor has been moved to.


pawn Код:
OnPlayerSelectColor(playerid, column, row)
Called when SelectCurrentColor(); is used. Use GetColorFromPosition(); to find out which vehicle color ID the user selected.


Information

I have included an example gamemode down below to give you an easy example of how to use the menu. It uses commands to move the cursor, but if you want you can also use your arrow keys, you simply have to re-code it that way. You could also leave the cursor out and make the colors clickable, but that will take some rewriting.
Remember, you don't have to use it the way I coded it, you can re-write it however you want, I simply provide you the color menu itself.


Download
Include:(Place the carcoldialog.inc into pawno/includes)
Reply
#2

Nice
Reply
#3

Nice script, well done.
Reply
#4

Nice. Could be used for many things, except cars!
Reply
#5

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
except cars!
Why so?
Reply
#6

Wow, Nice work Drebin.

REP+
Reply
#7

Updated to the new 0.3x colors, thanks to AIped!
Reply
#8

This is an old post, I know, however I seem to be getting the most strangest bug from this include.

pawn Код:
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerSelectColor" is not implemented
Any solutions? I have noticed you have forwarded it but don't have a public callback for it? Should there be one?
Reply
#9

Quote:
Originally Posted by LiamM
Посмотреть сообщение
This is an old post, I know, however I seem to be getting the most strangest bug from this include.

pawn Код:
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerChangeSelectedColor" is not implemented
error 004: function "OnPlayerSelectColor" is not implemented
Any solutions? I have noticed you have forwarded it but don't have a public callback for it? Should there be one?
Its because the script don't check if the callback is declared before calling it.

To fix this, you need to declare them!
pawn Код:
public OnPlayerChangeSelectedColor(playerid, column, row)
{
}

public OnPlayerSelectColor(playerid, column, row)
{
}
Reply
#10

Quote:
Originally Posted by Drebin
Посмотреть сообщение
I have included an example gamemode down below to give you an easy example of how to use the menu.
I do not see the example, anyone got an example ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)