12.01.2013, 14:42
(
Последний раз редактировалось d0; 01.02.2013 в 21:34.
)
mSelection(For SA-MP 0.3x and above)
(Translation: German translation/Deutsche Ьbersetzung)
A include which adds the possibility to create Model Preview Menus with only a few lines of code.
Updates
- 1.1 R3
Fixes Bug with blocking OnPlayerClick(Player)TextDraw
The selection menu instantly closed in all earlier verions if used/shown in OnDialogResponse
- 1.1 R2
Fixes bug when pressing ESC
- 1.1
Fixes bug when pressing ESC
Adds dynamic per player menus
Adds "cancel" button to the menus
- 1.0 R3:
Fixes bug with using ShowModelSelectionMenu in OnPlayerModelSelection
- 1.0 R2:
Adds possibility to use ShowModelSelectionMenu in OnPlayerModelSelection
Overview
Example #1 Static Lists
Scriptfiles: planes.txt - skins.txt
Example #2 Dynamic per player lists
Thanks to:
Kye: for creating vspawner.pwn
Downloads:
Include+Example Script+Scriptfiles: View attachments
(Translation: German translation/Deutsche Ьbersetzung)
A include which adds the possibility to create Model Preview Menus with only a few lines of code.
Updates
- 1.1 R3
Fixes Bug with blocking OnPlayerClick(Player)TextDraw
The selection menu instantly closed in all earlier verions if used/shown in OnDialogResponse
- 1.1 R2
Fixes bug when pressing ESC
- 1.1
Fixes bug when pressing ESC
Adds dynamic per player menus
Adds "cancel" button to the menus
- 1.0 R3:
Fixes bug with using ShowModelSelectionMenu in OnPlayerModelSelection
- 1.0 R2:
Adds possibility to use ShowModelSelectionMenu in OnPlayerModelSelection
Overview
pawn Код:
// for both (static and per player lists)
HideModelSelectionMenu(playerid)
//static lists
LoadModelSelectionMenu(f_name[])
ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
forward OnPlayerModelSelection(playerid, response, listid, modelid);
//dynamic per player lists
ShowModelSelectionMenuEx(playerid, items_array[], item_amount, header_text[], extraid, Float:Xrot = 0.0, Float:Yrot = 0.0, Float:Zrot = 0.0, Float:mZoom = 1.0, dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
forward OnPlayerModelSelectionEx(playerid, response, extraid, modelid);
- LoadModelSlectionMenu(f_name[])
Loads the menu content from a file and returns the listid.
- f_name[]: Filename of the list in your scriptfiles folder
- returns: ID of the list
Every line looks like: modelID xRot yRot zRot Zoom (The red ones are optional and don't have to be added)
Example Infernus ID 411:
Код:411 411 180.0 411 0.0 180.0 411 0.0 0.0 180.0 411 0.0 0.0 0.0 1.0
Example all planes: planes.txt
Код:460 16.0 0.0 -55.0 476 16.0 0.0 -55.0 511 16.0 0.0 -55.0 512 16.0 0.0 -55.0 513 16.0 0.0 -55.0 519 16.0 0.0 -55.0 520 16.0 0.0 -55.0 553 16.0 0.0 -55.0 577 16.0 0.0 -55.0 592 16.0 0.0 -55.0 593 16.0 0.0 -55.0
If more models use the same rotation/zoom information then the information will only be saved once to save memory.(For example 100 vehicles with the same rotation will only need one rotation to be saved)
- HideModelSelectionMenu(playerid)
Hide menu for player.
- playerid: playerid
- returns: nothing
- ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
Show menu for player.
- playerid: playerid
- ListID: The ID of the list/menu to be shown
- header_test[]: heading of the list/menu
- dialogBGcolor(optional): Look at the picture below for the color (*1)
- previewBGcolor(optional): Look at the picture below for the color (*2)
- tdSelectionColor(optional): Look at the picture below for the color (*3)
- returns: 1 success, 0 failed
- OnPlayerModelSelection(playerid, response, listid, modelid)
Called when a player selects a model or pressing esc
- playerid: playerid
- response: 1 = Model selected, 0 = canceled (esc)
- listid: The ID of the list
- modelid: selected model
- ShowModelSelectionMenuEx(playerid, items_array[], item_amount, header_text[], extraid, Float:Xrot = 0.0, Float:Yrot = 0.0, Float:Zrot = 0.0, Float:mZoom = 1.0, dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
Show menu for player.
- playerid: playerid
- items_array[]: Array of items to be shown
- item_amount: Amount of items in items_array[] (For example: item_amount = 3 would show items_array[0-2])
- header_test[]: heading of the list/menu
- extraid: extraid which gets passed to OnPlayerModelSelectionEx after selection
- Xrot: X rotation for the previews
- Yrot: Y rotation for the previews
- Zrot: Z rotation for the previews
- mZoom: Zoom for the previews
- dialogBGcolor(optional): Look at the picture below for the color (*1)
- previewBGcolor(optional): Look at the picture below for the color (*2)
- tdSelectionColor(optional): Look at the picture below for the color (*3)
- returns: 1 success, 0 failed
- OnPlayerModelSelectionEx(playerid, response, extraid, modelid)
Called when a player selects a model or pressing esc
- playerid: playerid
- response: 1 = Model selected, 0 = canceled (esc)
- extraid: The extraid used in ShowModelSelectionMenuEx
- modelid: selected model
Example #1 Static Lists
Scriptfiles: planes.txt - skins.txt
pawn Код:
#include <a_samp>
#include <mSelection>
new planelist = mS_INVALID_LISTID;
new skinlist = mS_INVALID_LISTID;
public OnFilterScriptInit()
{
planelist = LoadModelSelectionMenu("planes.txt");
skinlist = LoadModelSelectionMenu("skins.txt");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/plane", true) == 0)
{
ShowModelSelectionMenu(playerid, planelist, "->Planes<-");
return 1;
}
if(strcmp(cmdtext, "/changeskin", true) == 0)
{
ShowModelSelectionMenu(playerid, skinlist, "Select Skin");
return 1;
}
return 0;
}
public OnPlayerModelSelection(playerid, response, listid, modelid)
{
if(listid == planelist)
{
if(response)
{
SendClientMessage(playerid, 0xFF0000FF, "Plane Spawned");
new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
CreateVehicle(modelid, pos[0] + 2.5, pos[1], pos[2] + 2.5, 0.0, random(128), random(128), -1);
}
else SendClientMessage(playerid, 0xFF0000FF, "Canceled plane selection");
return 1;
}
if(listid == skinlist)
{
if(response)
{
SendClientMessage(playerid, 0xFF0000FF, "Skin Changed");
SetPlayerSkin(playerid, modelid);
}
else SendClientMessage(playerid, 0xFF0000FF, "Canceled skin selection");
return 1;
}
return 1;
}
pawn Код:
#include <a_samp>
#include <mSelection>
#define CUSTOM_TRAILER_MENU 1
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/selectVehicleTrailer", true) == 0)
{
new cars[15];
cars[0] = 435;
cars[1] = 450;
cars[2] = 569;
cars[3] = 570;
cars[4] = 584;
cars[5] = 590;
cars[6] = 591;
cars[7] = 606;
cars[8] = 607;
cars[9] = 608;
cars[10] = 610;
cars[11] = 611;
ShowModelSelectionMenuEx(playerid, cars, 12, "Select trailer", CUSTOM_TRAILER_MENU, 16.0, 0.0, -55.0);
return 1;
}
return 0;
}
public OnPlayerModelSelectionEx(playerid, response, extraid, modelid)
{
if(extraid == CUSTOM_TRAILER_MENU)
{
if(response)
{
SendClientMessage(playerid, 0xFF0000FF, "Trailer Spawned");
new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
CreateVehicle(modelid, pos[0] + 2.5, pos[1], pos[2] + 2.5, 0.0, random(128), random(128), -1);
}
else SendClientMessage(playerid, 0xFF0000FF, "Canceled trailer selection");
}
return 1;
}
Kye: for creating vspawner.pwn
Downloads:
Include+Example Script+Scriptfiles: View attachments