Admin system
#1

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.
Reply
#2

You can get some experience by looking at existing codes and understanding them.
Reply
#3

Ok im going to look for a sscanf tutorial
Reply
#4

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
Reply
#5

https://sampwiki.blast.hk/wiki/Fast_Commands#sscanf
Reply
#6

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.
Reply
#7

use dcmd + sccanf code or zcmd + sccanf code
Reply
#8

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
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)