SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 22/01/2017, 07:29 PM   #11
RyderX
Banned
 
Join Date: Oct 2016
Location: Lebanon,Beirut Rank: SA-MP Scripter
Posts: 564
Reputation: 53
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

Quote:
Originally Posted by Triggerz View Post
Where do I put the 'CMD:cuff' and 'CMD:uncuff' ?
First of all you have to download ZCMD - include from here: http://forum.sa-mp.com/showthread.php?t=91354

Then you have to include in your script:
PHP Code:
#include <zcmd> 
to let COMMAND and CMD Works, if you didn't include zcmd.inc so it'd get errors.

by the way if you downloaded the zcmd and putted it in Pawno>includes>zcmd.inc folder so just include it in your script as i have gave an example up, then when you gonna make a command so it would be like that:


PHP Code:
CMD:kill(playerid,params[])
{
       
SetPlayerHealth(playerid0.0);
       return 
1;

it's more easire than strcmp,

NOTE: You can use:
PHP Code:
CMD:123(playerid,params[])
{
     
//do something here
     
return 1;
}

//And you can use COMMAD like this:

COMMAND:123(playerid,params[])
{
      
//do something here
      
return 1;

Hope that i helped you
RyderX is offline   Reply With Quote
Old 22/01/2017, 07:35 PM   #12
PaRking
Banned
 
Join Date: Jan 2017
Location: 198.100.144.190:9865
Posts: 38
Reputation: 12
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

see here
http://forum.sa-mp.com/showthread.php?t=618127
and add it in gm
Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
Code:
CMD:cuff(playerid, params[])
{
      if(gTeam[playerid] == LSPD)
      {
            new targetid;
            if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)");
             if(IsPlayerConnected(targetid))
            {
                   new Float:x, Float:y, Float:z;
                   GetPlayerPos(targetid, x, y, z);
                   if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
                   {
                          if(gTeam[playerid] != LSPD)
                          {
                                 if(IsCuffed[targetid] == false)
                                 {
                                        new string[64+MAX_PLAYER_NAME]
                                        new targetname[MAX_PLAYER_NAME]
                                        new playername[MAX_PLAYER_NAME]
                                        GetPlayerName(playerid, playername, sizeof(playername)
                                        format(string, sizeof(string), "You have been cuffed by officer %s",playername));
                                        SendClientMessage(targetid, 0x0000FF, string);
                                        GetPlayerName(targetid, targetname, sizeof(targetname))
                                        format(string, sizeof(string), "You have cuffed %s ", targetname))
                                        SendClientMessage(playerid, 0xCCFF00, string));                                      SetPlayerAttachedObject(targetid,8,19418,6,-0.031999,0.024000,-0.024000,-7.900000,-32.000011,-72.299987,1.115998,1.322000,1.406000);
    	 				SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
                                        IsCuffed = true;
                                        return 1;
                                 }
                                 else if(IsCuffed == true)
                                 {
                                        SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is already cuffed!");
                                        return 1;
                                 }                            
                                 return 1;
                          }
                          else if(gTeam[playerid] == LSPD)
                          {
                                  SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't cuff a law enforcer!");
                                  return 1;
                          {
                          return 1;
                   }
                   else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
                   {
                          SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!");
                          return 1;
                   }
                   return 1;
            }
            else if(!IsPlayerConnected(targetid))
           {
                   SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!");
                   return 1!
           }
            return 1;
      }
      else if(gTeam[playerid] != LSPD)
      {
            SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!");
            return 1;
      }
      return 1;
}
Code:
CMD:uncuff(playerid, params[])
{
      if(gTeam[playerid] == LSPD)
      {
            new targetid;
            if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /uncuff (PlayerID)");
             if(IsPlayerConnected(targetid))
            {
                   new Float:x, Float:y, Float:z;
                   GetPlayerPos(targetid, x, y, z);
                   if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
                   {
                          if(gTeam[playerid] != LSPD)
                          {
                                 if(IsCuffed[targetid] == true)
                                 {
                                        new string[64+MAX_PLAYER_NAME]
                                        new targetname[MAX_PLAYER_NAME]
                                        new playername[MAX_PLAYER_NAME]
                                        GetPlayerName(playerid, playername, sizeof(playername)
                                        format(string, sizeof(string), "You have been uncuffed by officer %s",playername));
                                        SendClientMessage(targetid, 0x0000FF, string);
                                        GetPlayerName(targetid, targetname, sizeof(targetname))
                                        format(string, sizeof(string), "You have uncuffed %s ", targetname))
                                        SendClientMessage(playerid, 0xCCFF00, string));
                                        if(IsPlayerAttachedObjectSlotUsed(targetid, 8)) 
                                        {
				                 RemovePlayerAttachedObject(targetid, 8);
                                                 return 1;
					}
			         	SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE);
                                        IsCuffed = false;
                                        return 1;
                                 }
                                 else if(IsCuffed == true)
                                 {
                                        SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is not cuffed!");
                                        return 1;
                                 }                            
                                 return 1;
                          }
                          else if(gTeam[playerid] == LSPD)
                          {
                                  SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!");
                                  return 1;
                          {
                          return 1;
                   }
                   else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
                   {
                          SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!");
                          return 1;
                   }
                   return 1;
            }
            else if(!IsPlayerConnected(targetid))
           {
                   SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!");
                   return 1!
           }
            return 1;
      }
      else if(gTeam[playerid] != LSPD)
      {
            SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!");
            return 1;
      }
      return 1;
}
PaRking is offline   Reply With Quote
Old 22/01/2017, 07:36 PM   #13
RyderX
Banned
 
Join Date: Oct 2016
Location: Lebanon,Beirut Rank: SA-MP Scripter
Posts: 564
Reputation: 53
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

Quote:
Originally Posted by PaRking View Post
see here
http://forum.sa-mp.com/showthread.php?t=618127
and add it in gm
Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
Code:
CMD:cuff(playerid, params[])
{
      if(gTeam[playerid] == LSPD)
      {
            new targetid;
            if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /cuff (PlayerID)");
             if(IsPlayerConnected(targetid))
            {
                   new Float:x, Float:y, Float:z;
                   GetPlayerPos(targetid, x, y, z);
                   if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
                   {
                          if(gTeam[playerid] != LSPD)
                          {
                                 if(IsCuffed[targetid] == false)
                                 {
                                        new string[64+MAX_PLAYER_NAME]
                                        new targetname[MAX_PLAYER_NAME]
                                        new playername[MAX_PLAYER_NAME]
                                        GetPlayerName(playerid, playername, sizeof(playername)
                                        format(string, sizeof(string), "You have been cuffed by officer %s",playername));
                                        SendClientMessage(targetid, 0x0000FF, string);
                                        GetPlayerName(targetid, targetname, sizeof(targetname))
                                        format(string, sizeof(string), "You have cuffed %s ", targetname))
                                        SendClientMessage(playerid, 0xCCFF00, string));                                      SetPlayerAttachedObject(targetid,8,19418,6,-0.031999,0.024000,-0.024000,-7.900000,-32.000011,-72.299987,1.115998,1.322000,1.406000);
    	 				SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
                                        IsCuffed = true;
                                        return 1;
                                 }
                                 else if(IsCuffed == true)
                                 {
                                        SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is already cuffed!");
                                        return 1;
                                 }                            
                                 return 1;
                          }
                          else if(gTeam[playerid] == LSPD)
                          {
                                  SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't cuff a law enforcer!");
                                  return 1;
                          {
                          return 1;
                   }
                   else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
                   {
                          SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!");
                          return 1;
                   }
                   return 1;
            }
            else if(!IsPlayerConnected(targetid))
           {
                   SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!");
                   return 1!
           }
            return 1;
      }
      else if(gTeam[playerid] != LSPD)
      {
            SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!");
            return 1;
      }
      return 1;
}
Code:
CMD:uncuff(playerid, params[])
{
      if(gTeam[playerid] == LSPD)
      {
            new targetid;
            if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF00FF, "USAGE: /uncuff (PlayerID)");
             if(IsPlayerConnected(targetid))
            {
                   new Float:x, Float:y, Float:z;
                   GetPlayerPos(targetid, x, y, z);
                   if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
                   {
                          if(gTeam[playerid] != LSPD)
                          {
                                 if(IsCuffed[targetid] == true)
                                 {
                                        new string[64+MAX_PLAYER_NAME]
                                        new targetname[MAX_PLAYER_NAME]
                                        new playername[MAX_PLAYER_NAME]
                                        GetPlayerName(playerid, playername, sizeof(playername)
                                        format(string, sizeof(string), "You have been uncuffed by officer %s",playername));
                                        SendClientMessage(targetid, 0x0000FF, string);
                                        GetPlayerName(targetid, targetname, sizeof(targetname))
                                        format(string, sizeof(string), "You have uncuffed %s ", targetname))
                                        SendClientMessage(playerid, 0xCCFF00, string));
                                        if(IsPlayerAttachedObjectSlotUsed(targetid, 8)) 
                                        {
				                 RemovePlayerAttachedObject(targetid, 8);
                                                 return 1;
					}
			         	SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE);
                                        IsCuffed = false;
                                        return 1;
                                 }
                                 else if(IsCuffed == true)
                                 {
                                        SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is not cuffed!");
                                        return 1;
                                 }                            
                                 return 1;
                          }
                          else if(gTeam[playerid] == LSPD)
                          {
                                  SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!");
                                  return 1;
                          {
                          return 1;
                   }
                   else if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
                   {
                          SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!");
                          return 1;
                   }
                   return 1;
            }
            else if(!IsPlayerConnected(targetid))
           {
                   SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!");
                   return 1!
           }
            return 1;
      }
      else if(gTeam[playerid] != LSPD)
      {
            SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!");
            return 1;
      }
      return 1;
}
Nice explaining sir
RyderX is offline   Reply With Quote
Old 22/01/2017, 07:38 PM   #14
PaRking
Banned
 
Join Date: Jan 2017
Location: 198.100.144.190:9865
Posts: 38
Reputation: 12
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

he will not understand whit ur cmd: 123 -__________-
PaRking is offline   Reply With Quote
Old 22/01/2017, 07:39 PM   #15
RyderX
Banned
 
Join Date: Oct 2016
Location: Lebanon,Beirut Rank: SA-MP Scripter
Posts: 564
Reputation: 53
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

Quote:
Originally Posted by PaRking View Post
he will not understand whit ur cmd: 123 -__________-
Why he wouldn't? he isn't a scripts copier like you

and it's With not wtih
RyderX is offline   Reply With Quote
Old 22/01/2017, 07:40 PM   #16
Eoussama
High-roller
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 1,071
Reputation: 267
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

Quote:
Originally Posted by PaRking View Post
he will not understand whit ur cmd: 123 -__________-
tutorials are meant to be understood, not to copy code snippets from,
__________________

|===[Web taxi]===|
List of my work
Github
Pastebin

|===[Interesting topics]===|
Semantic Versioning
Eoussama is offline   Reply With Quote
Old 22/01/2017, 07:43 PM   #17
Triggerz
Little Clucker
 
Join Date: Jan 2017
Posts: 32
Reputation: 0
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

Quote:
Originally Posted by PaRking View Post
he will not understand whit ur cmd: 123 -__________-
For your information I wasn't copying at all. I was just trying to learn from it. I was analyzing it and learning from it and how to use <zcmd> and sscanf.
Triggerz is offline   Reply With Quote
Old 22/01/2017, 07:45 PM   #18
Triggerz
Little Clucker
 
Join Date: Jan 2017
Posts: 32
Reputation: 0
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

Quote:
Originally Posted by RyderX View Post
First of all you have to download ZCMD - include from here: http://forum.sa-mp.com/showthread.php?t=91354

Then you have to include in your script:
PHP Code:
#include <zcmd> 
to let COMMAND and CMD Works, if you didn't include zcmd.inc so it'd get errors.

by the way if you downloaded the zcmd and putted it in Pawno>includes>zcmd.inc folder so just include it in your script as i have gave an example up, then when you gonna make a command so it would be like that:


PHP Code:
CMD:kill(playerid,params[])
{
       
SetPlayerHealth(playerid0.0);
       return 
1;

it's more easire than strcmp,

NOTE: You can use:
PHP Code:
CMD:123(playerid,params[])
{
     
//do something here
     
return 1;
}

//And you can use COMMAD like this:

COMMAND:123(playerid,params[])
{
      
//do something here
      
return 1;

Hope that i helped you
thanks,

also, if I were to use 'IsPlayerAdmin' and else/if statements, how would I put it in 'CMD://cmd' is it the same way as 'OnPlayerCommand'?
Triggerz is offline   Reply With Quote
Old 22/01/2017, 07:49 PM   #19
RyderX
Banned
 
Join Date: Oct 2016
Location: Lebanon,Beirut Rank: SA-MP Scripter
Posts: 564
Reputation: 53
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

Quote:
Originally Posted by Triggerz View Post
thanks,

also, if I were to use 'IsPlayerAdmin' and else/if statements, how would I put it in 'CMD://cmd' is it the same way as 'OnPlayerCommand'?

Ye so it'll be like this:

PHP Code:
CMD:admin(playerid,params[])
{
      if(
IsPlayerAdmin(playerid)
      {
          
SendClientMessageToAll(0xf8f8f8fff,"he is an admin");
      }
      else
      {
       
SendClientMessage(playerid,0xf8f8f8888,"You aren't an RCON Admin to access to this shit");
      }
      return 
1;

RyderX is offline   Reply With Quote
Old 22/01/2017, 07:50 PM   #20
Eoussama
High-roller
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 1,071
Reputation: 267
Default Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD)

Quote:
Originally Posted by Triggerz View Post
thanks,

also, if I were to use 'IsPlayerAdmin' and else/if statements, how would I put it in 'CMD://cmd' is it the same way as 'OnPlayerCommand'?
Here is a simple example of closing a sevrer,

PHP Code:
//layout 1
CMD:exit(playerid){
      if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF0000"[ERROR]: You are not authorized to use this command");
      
SendRconCommand("exit");
      return 
1;
}
//layout 2
CMD:exit(playerid){
      if(
IsPlayerAdmin(playerid)){
             
SendRconCommand("exit");
      }
      else 
SendClientMessage(playerid0xFF0000"[ERROR]: You are not authorized to use this command");
      return 
1;

__________________

|===[Web taxi]===|
List of my work
Github
Pastebin

|===[Interesting topics]===|
Semantic Versioning
Eoussama is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with cuff and uncuff cmd with sscanf+zcmd. mittukuttan Scripting Help 1 31/01/2013 02:06 PM
Cuff/Uncuff striker25 Help Archive 47 17/07/2010 02:23 AM
Cuff/Uncuff ScottCFR Help Archive 6 19/03/2010 03:42 PM


All times are GMT. The time now is 02:36 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.