[HELP]Tele for only specific people? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Tele for only specific people? (
/showthread.php?tid=192006)
[HELP]Tele for only specific people? -
seifo - 21.11.2010
Hello guys
I've tried an failed so many times but can someone help me with making a tele for a certain group of people?
And a CMD that helps add people to that list?
For example
I have a group of people that has:
Jim
Willy
Star wars
and i Want it so only them three can use /teletowhatever
Can someone show me and example please, i've been trying all day
Re: [HELP]Tele for only specific people? -
Grim_ - 21.11.2010
You could simply store their IDs in an array and check if the ID matches, if so, make it happen:
pawn Код:
// Near the top of the script
new gCanUse[ MAX_PLAYERS ];
// In OnPlayerCommandText
new cmd[ 256 ], tmp [ 256 ], idx;
cmd = strtok( cmdtext, idx );
// The "Add" command
if( !strcmp( cmd, "/add", true ) )
{
if(!strlen(tmp)) return SendClientMessage( playerid, 0x00FF00FF, "Usage: /add <id>" );
if(!IsPlayerConnected(strval(tmp))) return SendClientMessage( playerid, 0x00FF00FF, "Invalid ID");
gCanUse[ strval(tmp) ] = 1;
SendClientMessage( playerid, 0x00FF00FF, "Player added");
SendClientMessage( strval(tmp), 0x00FF00FF, "You can now use the command" );
return 1;
}
// The command you need special permission to use
if( !strcmp(cmdtext, "/mycommand", true ) )
{
if( gCanUse[ playerid ] == 0 ) return SendClientMessage( playerid, 0x00FF00FF, "Error: You cannot use this command." );
// Do the rest of the command here
return 1;
}
// Under OnPlayerDisconnect
gCanUse[ playerid ] = 0;
This is a short and quick written example, hopefully you can understand and implement it into your script. Also, I do not usually recommend the strtok + strcmp method of doing commands, but it was the fastest I could type up. You may want to later change that into Zcmd, since it's the fastest command processor.
Re: [HELP]Tele for only specific people? -
seifo - 21.11.2010
what about multiple groups?
Re: [HELP]Tele for only specific people? -
Grim_ - 21.11.2010
Then it would get more complicated - Storing the player's group into a separate array along with the people in the group - Then check in the command if the group is like that of which I provided.