Wysłany: 2014-02-24, 14:18
KaNdY
Wiek: 29 Na forum: 4487 dni Posty: 53
Nick w MP: KaNdY
Piwa : 1
Witam, dosta?em tak?, mo?na to nazwa? wybiera?ka pojazd?w. Chodzi oto, ?e po wpisaniu /auta wyskakuj? textdrawy ze zdj?ciami aut i po klikni?ciu w niego spawnuje nam auto. Z racji tego, ?e tam by?a hydra, czo?g, itd. czego nie potrzebuj? usun??em z:
Kod:
new gItemList[TOTAL_ITEMS] = {
400,401,402,403,404,405,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,426,427,428,429,430,
431,433,434,435,436,437,438,439,440,441,442,443,445,446,448,450,451,452,453,454,455,456,457,458,459,460,461,
462,463,466,467,468,469,470,471,472,473,474,475,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,
493,494,495,496,497,498,499,500,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,521,522,523,
524,525,526,527,528,529,530,531,532,533,534,535,536,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,
555,558,559,560,561,562,563,565,566,567,568,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,
586,587,588,589,590,591,592,593,595,596,597,598,599,600,601,602,603,606,607,608,609
Mia?em 10 stron tych pojazd?w. Po usuni?ciu kilku, chcia?bym 9 stron, lecz nadal mam 10. A ostatnia wygl?da tak:
Pytanie brzmi, jak usun?? t? ostan? stron?, abym mia? 9.
Wysłany: 2014-02-24, 15:40
IgrexolonO
Wiek: 34 Na forum: 6810 dni Posty: 1386
Piwa : 1062
Mo?e w takim razie poka?esz nam kod tej bajecznej wybiera?ki?
Wysłany: 2014-02-24, 16:57
KaNdY
Wiek: 29 Na forum: 4487 dni Posty: 53
Nick w MP: KaNdY
Piwa : 1
Kod:
/* Sprowadz System */
#define TOTAL_ITEMS 207
#define SELECTION_ITEMS 21
#define ITEMS_PER_LINE 7
#define HEADER_TEXT "Serv4Drift"
#define NEXT_TEXT ">"
#define PREV_TEXT "<"
#define DIALOG_BASE_X 75.0
#define DIALOG_BASE_Y 130.0
#define DIALOG_WIDTH 550.0
#define DIALOG_HEIGHT 180.0
#define SPRITE_DIM_X 60.0
#define SPRITE_DIM_Y 70.0
new gTotalItems = TOTAL_ITEMS;
new PlayerText:gCurrentPageTextDrawId[MAX_PLAYERS];
new PlayerText:gHeaderTextDrawId[MAX_PLAYERS];
new PlayerText:gBackgroundTextDrawId[MAX_PLAYERS];
new PlayerText:gNextButtonTextDrawId[MAX_PLAYERS];
new PlayerText:gPrevButtonTextDrawId[MAX_PLAYERS];
new PlayerText:gSelectionItems[MAX_PLAYERS][SELECTION_ITEMS];
new gSelectionItemsTag[MAX_PLAYERS][SELECTION_ITEMS];
new gItemAt[MAX_PLAYERS];
new gItemList[TOTAL_ITEMS] = {
400,401,402,403,404,405,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,426,427,428,429,430,
431,433,434,435,436,437,438,439,440,441,442,443,445,446,448,450,451,452,453,454,455,456,457,458,459,460,461,
462,463,466,467,468,469,470,471,472,473,474,475,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,
493,494,495,496,497,498,499,500,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,521,522,523,
524,525,526,527,528,529,530,531,532,533,534,535,536,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,
555,558,559,560,561,562,563,565,566,567,568,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,
586,587,588,589,590,591,592,593,595,596,597,598,599,600,601,602,603,606,607,608,609
};
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
if(GetPVarInt(playerid, "vspawner_active") == 0) return 0;
new curpage = GetPVarInt(playerid, "vspawner_page");
if(playertextid == gNextButtonTextDrawId[playerid]) {
if(curpage < (GetNumberOfPages() - 1)) {
SetPVarInt(playerid, "vspawner_page", curpage + 1);
ShowPlayerModelPreviews(playerid);
UpdatePageTextDraw(playerid);
PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
} else {
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
}
return 1;
}
if(playertextid == gPrevButtonTextDrawId[playerid]) {
if(curpage > 0) {
SetPVarInt(playerid, "vspawner_page", curpage - 1);
ShowPlayerModelPreviews(playerid);
UpdatePageTextDraw(playerid);
PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
} else {
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
}
return 1;
}
new x=0;
while(x != SELECTION_ITEMS) {
if(playertextid == gSelectionItems[playerid][x]) {
HandlePlayerItemSelection(playerid, x);
PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
DestroySelectionMenu(playerid);
CancelSelectTextDraw(playerid);
SetPVarInt(playerid, "vspawner_active", 0);
return 1;
}
x++;
}
return 0;
}
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if(GetPVarInt(playerid, "vspawner_active") == 0) return 0;
if(clickedid == Text:INVALID_TEXT_DRAW) {
DestroySelectionMenu(playerid);
SetPVarInt(playerid, "vspawner_active", 0);
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
return 1;
}
return 0;
}
/* Sprowadz */
GetNumberOfPages()
{
if((gTotalItems >= SELECTION_ITEMS) && (gTotalItems % SELECTION_ITEMS) == 0)
{
return (gTotalItems / SELECTION_ITEMS);
}
else return (gTotalItems / SELECTION_ITEMS) + 1;
}
//------------------------------------------------
PlayerText:CreateCurrentPageTextDraw(playerid, Float:Xpos, Float:Ypos)
{
new PlayerText:txtInit;
txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, "0/0");
PlayerTextDrawUseBox(playerid, txtInit, 0);
PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
PlayerTextDrawFont(playerid, txtInit, 1);
PlayerTextDrawSetShadow(playerid, txtInit, 0);
PlayerTextDrawSetOutline(playerid, txtInit, 1);
PlayerTextDrawColor(playerid, txtInit, 0xBBBBBB);
PlayerTextDrawShow(playerid, txtInit);
return txtInit;
}
//------------------------------------------------
PlayerText:CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
{
new PlayerText:txtInit;
txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, button_text);
PlayerTextDrawUseBox(playerid, txtInit, 1);
PlayerTextDrawBoxColor(playerid, txtInit, 0x000000);
PlayerTextDrawBackgroundColor(playerid, txtInit, 0xFFFFFF);
PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
PlayerTextDrawFont(playerid, txtInit, 1);
PlayerTextDrawSetShadow(playerid, txtInit, 0);
PlayerTextDrawSetOutline(playerid, txtInit, 0);
PlayerTextDrawColor(playerid, txtInit, 0xFFFFFF);
PlayerTextDrawSetSelectable(playerid, txtInit, 1);
PlayerTextDrawAlignment(playerid, txtInit, 2);
PlayerTextDrawTextSize(playerid, txtInit, Height, Width);
PlayerTextDrawShow(playerid, txtInit);
return txtInit;
}
//------------------------------------------------
PlayerText:CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
{
new PlayerText:txtInit;
txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
PlayerTextDrawUseBox(playerid, txtInit, 0);
PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
PlayerTextDrawFont(playerid, txtInit, 0);
PlayerTextDrawSetShadow(playerid, txtInit, 0);
PlayerTextDrawSetOutline(playerid, txtInit, 1);
PlayerTextDrawColor(playerid, txtInit, 0xBBBBBB);
PlayerTextDrawShow(playerid, txtInit);
return txtInit;
}
//------------------------------------------------
PlayerText:CreatePlayerBackgroundTextDraw(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height)
{
new PlayerText:txtBackground = CreatePlayerTextDraw(playerid, Xpos, Ypos,
" ~n~");
PlayerTextDrawUseBox(playerid, txtBackground, 1);
PlayerTextDrawBoxColor(playerid, txtBackground, 0x00000099); //kolor t?a
PlayerTextDrawLetterSize(playerid, txtBackground, 5.0, 5.0);
PlayerTextDrawFont(playerid, txtBackground, 0);
PlayerTextDrawSetShadow(playerid, txtBackground, 0);
PlayerTextDrawSetOutline(playerid, txtBackground, 0);
PlayerTextDrawColor(playerid, txtBackground,0xBBBBBB);
PlayerTextDrawTextSize(playerid, txtBackground, Width, Height);
PlayerTextDrawBackgroundColor(playerid, txtBackground, 0xBBBBBB);
PlayerTextDrawShow(playerid, txtBackground);
return txtBackground;
}
//------------------------------------------------
PlayerText:CreateModelPreviewTextDraw(playerid, modelindex, Float:Xpos, Float:Ypos, Float:width, Float:height)
{
new PlayerText:txtPlayerSprite = CreatePlayerTextDraw(playerid, Xpos, Ypos, "");
PlayerTextDrawFont(playerid, txtPlayerSprite, TEXT_DRAW_FONT_MODEL_PREVIEW);
PlayerTextDrawColor(playerid, txtPlayerSprite, 0xFFFFFFFF);
PlayerTextDrawBackgroundColor(playerid, txtPlayerSprite, 0x000000EE); //Kolor t?a aut.
PlayerTextDrawTextSize(playerid, txtPlayerSprite, width, height);
PlayerTextDrawSetPreviewModel(playerid, txtPlayerSprite, modelindex);
PlayerTextDrawSetPreviewRot(playerid,txtPlayerSprite, -16.0, 0.0, -55.0);
PlayerTextDrawSetSelectable(playerid, txtPlayerSprite, 1);
PlayerTextDrawShow(playerid,txtPlayerSprite);
return txtPlayerSprite;
}
//------------------------------------------------
DestroyPlayerModelPreviews(playerid)
{
new x=0;
while(x != SELECTION_ITEMS) {
if(gSelectionItems[playerid][x] != PlayerText:INVALID_TEXT_DRAW) {
PlayerTextDrawDestroy(playerid, gSelectionItems[playerid][x]);
gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
}
x++;
}
}
//------------------------------------------------
ShowPlayerModelPreviews(playerid)
{
new x=0;
new Float:BaseX = DIALOG_BASE_X;
new Float:BaseY = DIALOG_BASE_Y - (SPRITE_DIM_Y * 0.33);
new linetracker = 0;
new itemat = GetPVarInt(playerid, "vspawner_page") * SELECTION_ITEMS;
DestroyPlayerModelPreviews(playerid);
while(x != SELECTION_ITEMS && itemat < gTotalItems) {
if(linetracker == 0) {
BaseX = DIALOG_BASE_X + 25.0;
BaseY += SPRITE_DIM_Y + 1.0;
}
gSelectionItems[playerid][x] = CreateModelPreviewTextDraw(playerid, gItemList[itemat], BaseX, BaseY, SPRITE_DIM_X, SPRITE_DIM_Y);
gSelectionItemsTag[playerid][x] = gItemList[itemat];
BaseX += SPRITE_DIM_X + 1.0;
linetracker++;
if(linetracker == ITEMS_PER_LINE) linetracker = 0;
itemat++;
x++;
}
}
//------------------------------------------------
UpdatePageTextDraw(playerid)
{
new PageText[64+1];
format(PageText, 64, "%d/%d", GetPVarInt(playerid,"vspawner_page") + 1, GetNumberOfPages());
PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
}
//------------------------------------------------
CreateSelectionMenu(playerid)
{
gBackgroundTextDrawId[playerid] = CreatePlayerBackgroundTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y + 20.0, DIALOG_WIDTH, DIALOG_HEIGHT);
gHeaderTextDrawId[playerid] = CreatePlayerHeaderTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y, HEADER_TEXT);
gCurrentPageTextDrawId[playerid] = CreateCurrentPageTextDraw(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y + 15.0);
gNextButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, NEXT_TEXT);
gPrevButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 90.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, PREV_TEXT);
ShowPlayerModelPreviews(playerid);
UpdatePageTextDraw(playerid);
}
//------------------------------------------------
DestroySelectionMenu(playerid)
{
DestroyPlayerModelPreviews(playerid);
PlayerTextDrawDestroy(playerid, gHeaderTextDrawId[playerid]);
PlayerTextDrawDestroy(playerid, gBackgroundTextDrawId[playerid]);
PlayerTextDrawDestroy(playerid, gCurrentPageTextDrawId[playerid]);
PlayerTextDrawDestroy(playerid, gNextButtonTextDrawId[playerid]);
PlayerTextDrawDestroy(playerid, gPrevButtonTextDrawId[playerid]);
gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
}
//------------------------------------------------
SpawnVehicle_InfrontOfPlayer(playerid, vehiclemodel, color1, color2)
{
new Float:x,Float:y,Float:z;
new Float:facing;
new Float:distance;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, facing);
new Float:size_x,Float:size_y,Float:size_z;
GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
distance = size_x + 0.5;
x += (distance * floatsin(-facing, degrees));
y += (distance * floatcos(-facing, degrees));
facing += 90.0;
if(facing > 360.0) facing -= 360.0;
return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
}
//------------------------------------------------
HandlePlayerItemSelection(playerid, selecteditem)
{
SpawnVehicle_InfrontOfPlayer(playerid, gSelectionItemsTag[playerid][selecteditem], -1, -1);
}
/* Sprowadz Koniec */
To chyba tyle.
Wysłany: 2014-02-24, 17:48
Rumun
Wiek: 30 Na forum: 5235 dni Posty: 316
Nick w MP: Rumun
Piwa : 25
Odejmij od 207 liczb? tych skin?w.
Cytat:
Tagi: spawn :: pojazdów
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: