Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "a_samp.inc"
- #file "Calc by FanHamMer"
- #define d_calc (0x83)
- public OnFilterScriptInit()
- {
- printf("Calc_"#by"_FanHamMer");
- return true;
- }
- public OnFilterScriptExit() return true;
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/calc", cmdtext, true, 10) == 0)
- {
- ShowPlayerDialog(playerid, d_calc, DIALOG_STYLE_INPUT, \
- "Calculator", "Enter a value 'a'", "Enter", "Cancel");
- return true;
- }
- return false;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- static a, b, c;
- switch(dialogid)
- {
- case d_calc:
- {
- if !response *then return true;
- if !strlen(inputtext) *then return true;
- a = strval(inputtext), \
- ShowPlayerDialog(playerid, d_calc+0b1, DIALOG_STYLE_INPUT, \
- "Calculator", "Enter a value 'b'", "Enter", "Cancel");
- }
- case d_calc+0x1:
- {
- if !response *then return true;
- if !strlen(inputtext) *then return true;
- b = strval(inputtext), \
- ShowPlayerDialog(playerid, d_calc+0b10, DIALOG_STYLE_INPUT,\
- "Calculator", "Enter the operator (*, /, -, +)", "Enter", "Cancel");
- }
- case d_calc+0b10:
- {
- if !response *then return true;
- if !strlen(inputtext) *then return true;
- static str[21];
- if strfind(inputtext, "+", true) != -1 *then
- c=a+b, format(str,21,"%i+%i = %d",a,b,c);
- if strfind(inputtext, "-", true) != -1 *then
- c=a-b, format(str,21,"%i-%i = %d",a,b,c);
- if strfind(inputtext, "*", true) != -1 *then
- c=a*b, format(str,21,"%i*%i = %d",a,b,c);
- if strfind(inputtext, "/", true) != -1 *then
- c=a/b, format(str,21,"%i/%i = %d",a,b,c);
- SendClientMessage(playerid,-1,str);
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement