i wiull help you with One command
First of all find SSCANF it's very easy and useful for /... [id] cmds
i'll help you with a /cuff cmd
first of all look at this page and add the whole code on the end of your script
https://sampwiki.blast.hk/wiki/Sscanf
put this under onplayercommandtext
Код:
{
dcmd(cuff, 4, cmdtext);
}
that wil make a cmd of the created cmd
now we make the cmd
don't put this under onplayercommandtext but just anywhere in your script
Код:
dcmd_cuff(playerid, params[])
{
if(gTeam[playerid] == TEAM_COPS){
new
id;
if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/cuff <playerid>\"");// if the player wont type a id after it
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");// if the id doesn't exist
else if(GetDistanceBetweenPlayers(playerid,id) > 3) SendClientMessage(playerid,donkerrood,"Player is too far away");// the player needs to be close to him
else if(gTeam[id] == TEAM_COPS) { SendClientMessage(playerid,donkerrood,"You can't cuff a cop"); }// cops cant cuff cops
else if(gTeam[playerid] != TEAM_COPS) { SendClientMessage(playerid,donkerrood,"You aren't a cop!"); }// if player isnt a cop
else if(TogglePlayerControllable(id,0)) SendClientMessage(playerid,donkerrood,"Player is already cuffed");// player is already cuffed
else
{
SendClientMessage(id,donkerrood,"You have been cuffed by a cop!");
TogglePlayerControllable(id, 0);
SendClientMessage(playerid, 0x00FF00AA, "You have cuffed the Player"); }// player cuffed now
}
return 1;
}
ok thats it 2 little tips
i use new gTeam[MAX_PLAYERS];
and getdistancebvetween players maybe you wanna use IsPlayerInRangeOfPoint but that is easier how to use that 2 search on wiki or chnage it with your own tramsystem
EDIT: this is the code for getdistancebetweenplayers
Код:
//-----------DISTANCE THING---------------//
stock Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)) return -1.00;
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
for gTeam alternative use your own teamsystem