Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <buttons>
- new Text:Header;
- new Text:Body;
- new Text: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++)
- {
- TextDrawDestroy(Text:i);
- //DestroyButtonForPlayer(playerid, Button:i);
- DestroyButton(Button:i);
- }
- }
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- //--------------------------------------------------------------------------
- // TEXTDRAWS FOR THE DIALOG LAYOUT
- //--------------------------------------------------------------------------
- Header = TextDrawCreate(190.000000, 126.000000, "Example Dialog with 3 buttons");
- TextDrawBackgroundColor(Header, 255);
- TextDrawFont(Header, 1);
- TextDrawLetterSize(Header, 0.400000, 1.000000);
- TextDrawColor(Header, -1);
- TextDrawSetOutline(Header, 1);
- TextDrawSetProportional(Header, 1);
- TextDrawUseBox(Header, 1);
- TextDrawBoxColor(Header, 255);
- TextDrawTextSize(Header, 470.000000, 0.000000);
- Body = TextDrawCreate(190.000000, 141.000000, "_");
- TextDrawBackgroundColor(Body, 255);
- TextDrawFont(Body, 1);
- TextDrawLetterSize(Body, 0.400000, 11.499990);
- TextDrawColor(Body, -1);
- TextDrawSetOutline(Body, 1);
- TextDrawSetProportional(Body, 1);
- TextDrawUseBox(Body, 1);
- TextDrawBoxColor(Body, 150);
- TextDrawTextSize(Body, 470.000000, 0.000000);
- TDText = TextDrawCreate(328.000000, 161.000000, "Do you want to save this text~n~in a file~n~~y~(Will not really be saved)");
- TextDrawAlignment(TDText, 2);
- TextDrawBackgroundColor(TDText, 255);
- TextDrawFont(TDText, 1);
- TextDrawLetterSize(TDText, 0.470000, 1.500000);
- TextDrawColor(TDText, -1);
- TextDrawSetOutline(TDText, 1);
- TextDrawSetProportional(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++)
- {
- TextDrawDestroy(Text: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)
- {
- TextDrawShowForPlayer(playerid, Header);
- TextDrawShowForPlayer(playerid, Body);
- TextDrawShowForPlayer(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)
- {
- SendClientMessageToAll(-1, "LOL");
- if(_:clickedid == INVALID_TEXT_DRAW)
- {
- TextDrawHideForPlayer(playerid, Header);
- TextDrawHideForPlayer(playerid, Body);
- TextDrawHideForPlayer(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...");
- TextDrawHideForPlayer(playerid, Header);
- TextDrawHideForPlayer(playerid, Body);
- TextDrawHideForPlayer(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
Advertisement