28.03.2012, 19:21
(
Последний раз редактировалось Hiddos; 28.04.2012 в 12:14.
)
I took a look at the clickable textdraw shit and it's pretty neat tbh. I decided to use it for some sort.
YOU NEED 0.3e RC5 OR HIGHER FOR THIS TO RUN!!
I'll skip the useless text nobody reads. Here are screenshots.
The player list comes with a function and a callback. Use InputFromPlayerList(); to show the list and allow the player to select somebody. When the player has selected somebody, the data will be passed to OnPlayerSelectPlayer.
An example of a script that bans the (selected) player.
The max length of the keypad input is 16 digits. The amount of max digits can be controlled. Like the player list, it comes with a function to enable it and a callback to output all data.
Since 1.0.5:
A note on the length parameters: If minlen is zero or below zero, it'll default to 1.
OnPlayerKeypadInput returns the input in a string (!), instead of an integer, because 32 bit integers can't be longer than 10 digits. If you're using a maxlen of 9 or below, you can simply use strval. (You most probably won't need to input up to 16 chars anyway)
Guess that'll get ya going. Here's an example though:
SolidFiles
Pastebin.com
Updates to PVars, which in this script would be better.
If the player is allowed to close the input, pressing escape will do the trick as well.
Fixed a possible, but not confirmed bug regarding players joining/leaving and not updating the player list.
It's possible to stop a player from inputting something, using CancelInput.
Doesn't need the use of a filterscript anymore, include it in any script!
1.0 -
Initial release
- Kar (testing)
- Jochemd (testing)
- Approx 140 bots (testing)
YOU NEED 0.3e RC5 OR HIGHER FOR THIS TO RUN!!
I'll skip the useless text nobody reads. Here are screenshots.
Player list
The player list can be used to easily select another player, to be used in a form. Or something else, whatever suits you best. I guess it could be nice in for example vote kick or teleport commands. Administrating users wouldn't be a bad idea either. Or you could just use it to replace the tab list. Use it to your likings.The player list comes with a function and a callback. Use InputFromPlayerList(); to show the list and allow the player to select somebody. When the player has selected somebody, the data will be passed to OnPlayerSelectPlayer.
pawn Код:
native InputFromPlayerList(playerid, event, bool:allowcancel);
// playerid - the player to use the list
// event - similar to the id when using dialogs. Use it to tell what you're doing.
// allowcancel > set this to true if you'd like to allow the user to cancel selecting
// a player from the list, returning INVALID_PLAYER_ID (An 'x' icon will appear, which the player can click on). Set it to false to disable the icon.
forward OnPlayerSelectPlayer(playerid, targetid, event);
// playerid - the player who selected another player
// targetid - the target the player selected
// event - the event you used when starting the list showing thingy.
pawn Код:
#define EVENT_BAN 1
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/ban", true))
{
InputFromPlayerList(playerid, EVENT_BAN, true);
return 1;
}
return 0;
}
public OnPlayerSelectPlayer(playerid, targetid, event) // Doesn't handle returns, btw.
{
if(event == EVENT_BAN && targetid != INVALID_PLAYER_ID)
{
Ban(targetid);
}
}
Keypad
The keypad can be used to input digits. Yes, I do say. This can be used for a lot of things, like bank PINs or calling other people if you're using a phone system. Perhaps even make babies pregnant, but I never tried that out.The max length of the keypad input is 16 digits. The amount of max digits can be controlled. Like the player list, it comes with a function to enable it and a callback to output all data.
pawn Код:
native InputFromKeypad(playerid, event, len, bool:allowcancel);
// playerid - see player list
// event - see player list
// minlen - the minimum length of the input. Defaults to 1 if between
// maxlen - the max length of the input. Choose from a range between 1 and 16. Invalid values default to 16.
// allowcancel - see player list
forward OnPlayerKeypadInput(playerid, input[], event);
// playerid - the player who used the keypad to input something
// input - Whatever number the player has put in.
// event - The event you use.. See player list
A note on the length parameters: If minlen is zero or below zero, it'll default to 1.
OnPlayerKeypadInput returns the input in a string (!), instead of an integer, because 32 bit integers can't be longer than 10 digits. If you're using a maxlen of 9 or below, you can simply use strval. (You most probably won't need to input up to 16 chars anyway)
Guess that'll get ya going. Here's an example though:
pawn Код:
#define EVENT_SETHP 2
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/sethp", true))
{
InputFromKeypad(playerid, EVENT_SETHP, 1, 2 true);
return 1;
}
return 0;
}
public OnPlayerKeypadInput(playerid, input[], event) // Doesn't handle returns, btw.
{
if(event == EVENT_SETHP)
{
SetPlayerHealth(playerid, floatstr(input));
}
}
Misc
If you want the player to do something else than input stuffs, you can cancel it this way:pawn Код:
native CancelInput(playerid);
Download
Use this SolidFiles link and put the include in the /pawno/include folder.SolidFiles
Pastebin.com
Changelog
1.0.5 - Updates to PVars, which in this script would be better.
If the player is allowed to close the input, pressing escape will do the trick as well.
Fixed a possible, but not confirmed bug regarding players joining/leaving and not updating the player list.
It's possible to stop a player from inputting something, using CancelInput.
Doesn't need the use of a filterscript anymore, include it in any script!
1.0 -
Initial release
Archive
1.0 SolidFiles (initial release, requires you to use InputInit before use. Definitely not recommended)Credits
Special credits go to..- Kar (testing)
- Jochemd (testing)
- Approx 140 bots (testing)