Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <buttons>
- new PlayerText:Header;
- new PlayerText:Body;
- new PlayerText:TDText;
- new Button:btn1;
- new Button:btn2;
- new Button:btn3;
- new Button:moneybutton;
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Buttons Test Filterscript by SpiritEvil");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new playerid = 0; playerid <= MAX_PLAYERS; playerid++)
- {
- for(new i = 0; i <= MAX_TEXT_DRAWS; i++)
- {
- PlayerTextDrawDestroy(playerid, PlayerText:i);
- }
- }
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- //--------------------------------------------------------------------------
- // TEXTDRAWS FOR THE DIALOG LAYOUT
- //--------------------------------------------------------------------------
- Header = CreatePlayerTextDraw(playerid, 190.000000, 126.000000, "Example Dialog with 3 buttons");
- PlayerTextDrawBackgroundColor(playerid, Header, 255);
- PlayerTextDrawFont(playerid, Header, 1);
- PlayerTextDrawLetterSize(playerid, Header, 0.400000, 1.000000);
- PlayerTextDrawColor(playerid, Header, -1);
- PlayerTextDrawSetOutline(playerid, Header, 1);
- PlayerTextDrawSetProportional(playerid, Header, 1);
- PlayerTextDrawUseBox(playerid, Header, 1);
- PlayerTextDrawBoxColor(playerid, Header, 255);
- PlayerTextDrawTextSize(playerid, Header, 470.000000, 0.000000);
- Body = CreatePlayerTextDraw(playerid, 190.000000, 141.000000, "_");
- PlayerTextDrawBackgroundColor(playerid, Body, 255);
- PlayerTextDrawFont(playerid, Body, 1);
- PlayerTextDrawLetterSize(playerid, Body, 0.400000, 11.499990);
- PlayerTextDrawColor(playerid, Body, -1);
- PlayerTextDrawSetOutline(playerid, Body, 1);
- PlayerTextDrawSetProportional(playerid, Body, 1);
- PlayerTextDrawUseBox(playerid, Body, 1);
- PlayerTextDrawBoxColor(playerid, Body, 150);
- PlayerTextDrawTextSize(playerid, Body, 470.000000, 0.000000);
- TDText = CreatePlayerTextDraw(playerid, 328.000000, 161.000000, "Do you want to save this text~n~in a file~n~~y~(Will not really be saved)");
- PlayerTextDrawAlignment(playerid, TDText, 2);
- PlayerTextDrawBackgroundColor(playerid, TDText, 255);
- PlayerTextDrawFont(playerid, TDText, 1);
- PlayerTextDrawLetterSize(playerid, TDText, 0.470000, 1.500000);
- PlayerTextDrawColor(playerid, TDText, -1);
- PlayerTextDrawSetOutline(playerid, TDText, 1);
- PlayerTextDrawSetProportional(playerid, TDText, 1);
- //--------------------------------------------------------------------------
- // Creating the buttons
- //--------------------------------------------------------------------------
- btn1 = CreateButtonForPlayer(playerid, "Save", 205, 215, 55, 20);
- ChangeButtonColorsForPlayer(playerid, btn1, 0x000000FF, 0x39C221FF, 0xFFFFFFFF);
- btn2 = CreateButtonForPlayer(playerid, "Don'tSave", 278, 215, 100, 20);
- ChangeButtonColorsForPlayer(playerid, btn2, 0x000000FF, 0xFF0000FF, 0xFFFFFFFF);
- btn3 = CreateButtonForPlayer(playerid, "Cancel", 395, 215, 65, 20);
- ChangeButtonColorsForPlayer(playerid, btn3, 0x000000FF, 0xFFFF00FF, 0xFFFFFFFF);
- //------------------------------- Money Button -----------------------------
- moneybutton = CreateButtonForPlayer(playerid, "$$Click For Money$$", 210, 150, 200, 40);
- //We are using the default colors here (black for stroke, red for button and white for text)
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- for(new i = 0; i <= MAX_TEXT_DRAWS; i++)
- {
- PlayerTextDrawDestroy(playerid, PlayerText:i);
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SendClientMessage(playerid, -1, "Use /testbuttons or /moneybutton to test the buttons!");
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/testbuttons", cmdtext, true, 10) == 0)
- {
- PlayerTextDrawShow(playerid, Header);
- PlayerTextDrawShow(playerid, Body);
- PlayerTextDrawShow(playerid, TDText);
- ShowButtonForPlayer(playerid, btn1);
- ShowButtonForPlayer(playerid, btn2);
- ShowButtonForPlayer(playerid, btn3);
- return 1;
- }
- if (strcmp("/moneybutton", cmdtext, true, 10) == 0)
- {
- ShowButtonForPlayer(playerid, moneybutton);
- SendClientMessage(playerid, -1, "To change the button's colors type /colors and to change the text type /text");
- SetPVarInt(playerid, "MoneyButton", 1);
- return 1;
- }
- if (strcmp("/colors", cmdtext, true, 10) == 0)
- {
- if(GetPVarInt(playerid, "MoneyButton") == 0) return SendClientMessage(playerid, 0xFF000FF, "You must type /moneybutton first!");
- new Colors[] =
- {
- 0xFF0000FF,
- 0xFFFF00FF,
- 0x852479FF,
- 0x3AE048FF,
- 0xFFB508FF,
- 0xDE5DDCFF,
- 0x15D8E6FF,
- 0x15D8E6FF
- };
- new rand1 = random(sizeof(Colors));
- new rand2 = random(sizeof(Colors));
- new rand3 = random(sizeof(Colors));
- ChangeButtonColorsForPlayer(playerid, moneybutton, Colors[rand1], Colors[rand2], Colors[rand3]);
- UpdateButtonForPlayer(playerid, moneybutton);
- return 1;
- }
- if (strcmp("/text", cmdtext, true, 10) == 0)
- {
- if(GetPVarInt(playerid, "MoneyButton") == 0) return SendClientMessage(playerid, 0xFF000FF, "You must type /moneybutton first!");
- new text[][] =
- {
- {"$$Click For Money$$"},
- {"!!!Free Cash FTW!!!"},
- {"$.................$"},
- {"Click me for Free $"}
- };
- new rand1 = random(sizeof(text));
- SetButtonTextForPlayer(playerid, moneybutton, text[rand1]);
- return 1;
- }
- return 0;
- }
- public OnPlayerClickTextDraw(playerid, Text:clickedid)
- {
- if(_:clickedid == INVALID_TEXT_DRAW)
- {
- PlayerTextDrawHide(playerid, Header);
- PlayerTextDrawHide(playerid, Body);
- PlayerTextDrawHide(playerid, TDText);
- HideButtonForPlayer(playerid, btn1);
- HideButtonForPlayer(playerid, btn2);
- HideButtonForPlayer(playerid, btn3);
- HideButtonForPlayer(playerid, moneybutton);
- }
- return 1;
- }
- public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
- {
- B_OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid);
- return 1;
- }
- public OnPlayerClickButton(playerid, Button:btnid)
- {
- if(btnid == btn1)
- {
- SendClientMessage(playerid, -1, "File will be saved!");
- }
- else if(btnid == btn2)
- {
- SendClientMessage(playerid, -1, "File will NOT be saved!");
- }
- else if(btnid == btn3)
- {
- SendClientMessage(playerid, -1, "Canceling...");
- PlayerTextDrawHide(playerid, Header);
- PlayerTextDrawHide(playerid, Body);
- PlayerTextDrawHide(playerid, TDText);
- HideButtonForPlayer(playerid, btn1);
- HideButtonForPlayer(playerid, btn2);
- HideButtonForPlayer(playerid, btn3);
- CancelSelectTextDraw(playerid);
- }
- else if(btnid == moneybutton)
- {
- GivePlayerMoney(playerid, 1);
- SendClientMessage(playerid, 0x36B32BFF, "+$1");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment