Admin system - 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: Admin system (
/showthread.php?tid=274135)
Admin system -
SpankMe2 - 04.08.2011
Hey Guy's,
So im a sort of beginer at scripting and clearly im on my first gamemode.
Can you tell me how i can work out who's sent the command to ban somone for example and who they are banning please do not post scripts as i really want to get some experiance in this.
System - SSCANF2
Thanks for your help.
Re: Admin system -
MadeMan - 04.08.2011
You can get some experience by looking at existing codes and understanding them.
Re: Admin system -
SpankMe2 - 04.08.2011
Ok im going to look for a sscanf tutorial
Re: Admin system -
SpankMe2 - 04.08.2011
so im looking at this tutorial
https://sampforum.blast.hk/showthread.php?tid=120356
i cant work out what i use to find my target player so i dont ban myself
Re: Admin system -
MadeMan - 04.08.2011
https://sampwiki.blast.hk/wiki/Fast_Commands#sscanf
Re: Admin system -
PrawkC - 04.08.2011
Heres a simple understanding to sscanf.. heres an example..
we have the variables, reason and target.. target will be the person we want banned, and reason is going to be the reason, and its a string.
sscanf(params, "us", target, reason);
now what that does is, it grabs the params and makes the first param become the target, and the second become reason. . and the "us" is just defining what the two params are, u "user", s "string" .. So when you do Ban(target) it would ban what ever you put as the first param IE, /cmd FIRST SECOND .. so it'd ban "FIRST" .. though obviously that wouldn't work as you need the variable to be a ID.
edit: Or what made man said.
Re: Admin system -
Tigerkiller - 04.08.2011
use dcmd + sccanf code or zcmd + sccanf code
Re: Admin system -
SpankMe2 - 04.08.2011
Quote:
Originally Posted by PrawkC
Heres a simple understanding to sscanf.. heres an example..
we have the variables, reason and target.. target will be the person we want banned, and reason is going to be the reason, and its a string.
sscanf(params, "us", target, reason);
now what that does is, it grabs the params and makes the first param become the target, and the second become reason. . and the "us" is just defining what the two params are, u "user", s "string" .. So when you do Ban(target) it would ban what ever you put as the first param IE, /cmd FIRST SECOND .. so it'd ban "FIRST" .. though obviously that wouldn't work as you need the variable to be a ID.
edit: Or what made man said.
|
Oh i see im going to make the code now and try it out.
It seems so simple when you write it
Thanks to Mademan and PrawkC
Edit:
Quote:
Originally Posted by Tigerkiller
use dcmd + sccanf code or zcmd + sccanf code
|
I use y_cmd i think its better for me to learn the latest systems
but Thanks Tigerkiller
Re: Admin system -
Scarred - 04.08.2011
It's kinda impossible to explain it without using code - So here's my go at it.
In sscanf you use specifiers, these specifiers help the system decide what you're trying to use as parameters; Like so:
pawn Код:
new Player;
if(sscanf(params, "u", Player)) //what happens if they just type "/commandname"?
return SendClientMessage(playerid, -1, "Usage: /commandname [playerid]");
//what happens if they use the correct parameters?
new string[128], player_Name[MAX_PLAYER_NAME];
GetPlayerName(Player, player_Name, sizeof(player_Name));
format(string, sizeof(string), "You've typed: \"/commandname %d\", and have selected %s! (ID: %d)", Player, player_Name, Player);
SendClientMessage(playerid, -1, string); //Sends YOU this message.
In this example, "Player" is the ID you have selected, and "playerid" is the person who has typed the command.
I hope this helped.