SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 13/07/2012, 08:53 PM   #1
kbalor
High-roller
 
kbalor's Avatar
 
Join Date: May 2012
Location: Philippines
Posts: 1,224
Reputation: 54
Default Disable all Commands Except...

How can I disable all commands except.

This /w - weapons menu /v- vehicle menu /stats /pm and so on..

I have here an example where i want to enable those commands.

Code:
CMD:drag(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)){
        SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821);
		CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor
        SetPlayerFacingAngle(playerid, 0.0);
        SetPlayerInterior(playerid, 0);
        new string[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName);
        SendClientMessageToAll(playerid, string);
        SetPlayerVirtualWorld(playerid, 1);
    }
    else{
        new veh = GetPlayerVehicleID(playerid);
        LinkVehicleToInterior(veh, 0);
        SetVehiclePos(veh, -2911.2407,-194.6217,2.7821);
        SetVehicleZAngle(veh, 0.0);
        SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821);
		CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor
        new string[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName);
        SendClientMessageToAll(playerid, string);
        PutPlayerInVehicle(playerid, veh, 0);
        SetVehicleVirtualWorld(veh, 1);
        SetPlayerVirtualWorld(playerid, 1);
    }
    return SendClientMessage(playerid, 0xFF0000FF, "You have been teleported to Drag Arena");
}
__________________
kbalor is offline   Reply With Quote
Old 13/07/2012, 08:58 PM   #2
Roko_foko
Gangsta
 
Join Date: Jul 2009
Location: Croatia, Split
Posts: 542
Reputation: 37
Default Re: Disable all Commands Except...

make a variable that will show if the commands are disabled or not for each player.
pawn Code:
new bool:gCommandsDisabled[MAX_PLAYERS];
and on every command in the beginning put if(gCommandsDisabled[playerid]==false)return SendClientMessage(playerid,0xFF0000,"More luck next time!");
pawn Code:
OnPlayerCommandText(playerid,...)
{
    if(strcmp("/suicide",cmdtext)==0)
    {
           if(gCommandsDisabled[playerid]==true)return SendClientMessage(playerid,0xFF0000FF,"More luck next time!");
           //^^^^EDITED, was false, but have to be true
           //....
}
to enable just
pawn Code:
gCommandsDisabled[playerid]==false;// EDITED - switched enabling/disabling
to disable
pawn Code:
gCommandsDisabled[playerid]=true;
Roko_foko is offline   Reply With Quote
Old 13/07/2012, 09:00 PM   #3
kbalor
High-roller
 
kbalor's Avatar
 
Join Date: May 2012
Location: Philippines
Posts: 1,224
Reputation: 54
Default Re: Disable all Commands Except...

Quote:
Originally Posted by Roko_foko View Post
make a variable that will show if the commands are disabled or not.

new bool:gCommandsDisabled[MAX_PLAYERS];

and on every command in the beginning put if(gCommandsDisabled[playerid]==false)return SendClientMessage...

to enable just gCommandsDisabled[playerid]==true;
to disable gCommandsDisabled[playerid]=false;
Can you make a demo? so i have a pattern to continue without hesitation.
__________________
kbalor is offline   Reply With Quote
Old 13/07/2012, 09:00 PM   #4
Roko_foko
Gangsta
 
Join Date: Jul 2009
Location: Croatia, Split
Posts: 542
Reputation: 37
Default Re: Disable all Commands Except...

i have edited my first post
Roko_foko is offline   Reply With Quote
Old 13/07/2012, 09:10 PM   #5
kbalor
High-roller
 
kbalor's Avatar
 
Join Date: May 2012
Location: Philippines
Posts: 1,224
Reputation: 54
Default Re: Disable all Commands Except...

Quote:
Originally Posted by Roko_foko View Post
i have edited my first post
im confused. So I can't use /suicide command everywhere?

Edit: What if i leave /drag and go to other place like /aa, Can suicide automatically enabled in /aa??
__________________
kbalor is offline   Reply With Quote
Old 13/07/2012, 09:21 PM   #6
Larceny
Big Clucker
 
Larceny's Avatar
 
Join Date: Apr 2006
Location: base64
Posts: 187
Reputation: 151
Default Re: Disable all Commands Except...

Are you using zcmd, right?

You can use this:

pawn Code:
public OnPlayerCommandReceived(playerid, cmdtext[])// ZCMD's callback.
{
    //Example of condition \/-------------Example of command \/
    if( IsPlayerLogged(playerid) == 0 && strcmp(cmdtext, "/login", true) != 0)
        return SendClientMessage(playerid, -1, "You are not logged."), 0;
        //--------------------Example of messange /\

    return 1;
}
Larceny is offline   Reply With Quote
Old 13/07/2012, 09:23 PM   #7
Roko_foko
Gangsta
 
Join Date: Jul 2009
Location: Croatia, Split
Posts: 542
Reputation: 37
Default Re: Disable all Commands Except...

Quote:
Originally Posted by kbalor View Post
im confused. So I can't use /suicide command everywhere?

Edit: What if i leave /drag and go to other place like /aa, Can suicide automatically enabled in /aa??
That depends on scripter(you). If you want to disable the commands after player go to some other place(or after they killed someone, or after they have been prisoned, or any other YOUR reason) via command (or entering check point, or idk... picking pickup) just put
pawn Code:
gCommandsDisabled[playerid]=true;
and they wont be able to use that commands.

for example I don't want player to /suicide after he uses command /teleport, but if really needed player can use command /sorry to enable commands:
pawn Code:
OnPlayerCommandText(playerid,cmdtext[])
{
     if(strcmp(cmdtext,"/teleport")==0)
     {
         SetPlayerPos(playerid,0,1,2);
         gCommandsDisabled[playerid]==true;
         return 1;
     }
     if(strcmp("/suicide",cmdtext)==0)
     {
         if(gCommandsDisabled[playerid]==true)return SendClientMessage(playerid,0xFF0000FF,"More luck next time!");
         SetPlayerHealth(playerid,0);
         return 1;
     }
     if(strcmp("/sorry",cmdtext)==0)
     {
         gCommandsDisabled[playerid]==false;
         return 1;
     }
}
Roko_foko is offline   Reply With Quote
Old 14/07/2012, 09:35 AM   #8
kbalor
High-roller
 
kbalor's Avatar
 
Join Date: May 2012
Location: Philippines
Posts: 1,224
Reputation: 54
Default Re: Disable all Commands Except...

Quote:
Originally Posted by Roko_foko View Post
That depends on scripter(you). If you want to disable the commands after player go to some other place(or after they killed someone, or after they have been prisoned, or any other YOUR reason) via command (or entering check point, or idk... picking pickup) just put
pawn Code:
gCommandsDisabled[playerid]=true;
and they wont be able to use that commands.

for example I don't want player to /suicide after he uses command /teleport, but if really needed player can use command /sorry to enable commands:
pawn Code:
OnPlayerCommandText(playerid,cmdtext[])
{
     if(strcmp(cmdtext,"/teleport")==0)
     {
         SetPlayerPos(playerid,0,1,2);
         gCommandsDisabled[playerid]==true;
         return 1;
     }
     if(strcmp("/suicide",cmdtext)==0)
     {
         if(gCommandsDisabled[playerid]==true)return SendClientMessage(playerid,0xFF0000FF,"More luck next time!");
         SetPlayerHealth(playerid,0);
         return 1;
     }
     if(strcmp("/sorry",cmdtext)==0)
     {
         gCommandsDisabled[playerid]==false;
         return 1;
     }
}
Thanks but i dont want player to type manual if they want to enable or disable their commands even I.

Okay to make it simple.

I only want to disable /t -teleport command in drag. If you can see on my first post.

If player tried to use /t- teleport a DIALOG_STYLE_MSGBOX will show "You can't use teleport while in Drag" "Leave" "Stay"

If player click Leave - He will die and respawn in different spawn place.
If player click stay - Dialog will close and he/she still in drag area.
__________________
kbalor is offline   Reply With Quote
Old 14/07/2012, 10:01 AM   #9
kbalor
High-roller
 
kbalor's Avatar
 
Join Date: May 2012
Location: Philippines
Posts: 1,224
Reputation: 54
Default Re: Disable all Commands Except...

Edit: You'll understand now.
__________________
kbalor is offline   Reply With Quote
Old 14/07/2012, 10:14 AM   #10
Roko_foko
Gangsta
 
Join Date: Jul 2009
Location: Croatia, Split
Posts: 542
Reputation: 37
Default Re: Disable all Commands Except...

pawn Code:
CMD:drag(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)){
        SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821);
        CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor
        SetPlayerFacingAngle(playerid, 0.0);
        SetPlayerInterior(playerid, 0);
        new string[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName);
        SendClientMessageToAll(playerid, string);
        SetPlayerVirtualWorld(playerid, 1);
    }
    else{
        new veh = GetPlayerVehicleID(playerid);
        LinkVehicleToInterior(veh, 0);
        SetVehiclePos(veh, -2911.2407,-194.6217,2.7821);
        SetVehicleZAngle(veh, 0.0);
        SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821);
        CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor
        new string[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName);
        SendClientMessageToAll(playerid, string);
        PutPlayerInVehicle(playerid, veh, 0);
        SetVehicleVirtualWorld(veh, 1);
        SetPlayerVirtualWorld(playerid, 1);
    }
    gCommandsDisabled[playerid]==true;//add this <-<-<-<-<-<-<-<-<-<
    return SendClientMessage(playerid, 0xFF0000FF, "You have been teleported to Drag Arena");

}

pawn Code:
OnPlayerCommandText(playerid,cmdtext[])
{
     if(strcmp(cmdtext,"/t")==0 && cmdtext[2]=='\0')
     {
          if(gCommandsDisabled[playerid]==true)
          {
                // Now show him the dialog
                return 1:
          }
            //...
     }

so after the command /drag is used, the /t command is not available for player.
Once you want to enable the command, for example: when player dies just put the gCOmmandsDisabled[playerid]=false;
pawn Code:
OnPlayerDeath(//blah blah)
{
     gCOmmandsDisabled[playerid]=false;
     //rest of the code
}
Roko_foko 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
How to disable commands in jail? Sensitive Scripting Help 27 25/08/2011 12:46 PM
How to disable commands? Ernests Help Archive 2 30/04/2011 01:47 PM
Disable Commands CraZy_KiLLaH Help Archive 1 20/03/2011 07:38 PM
disable commands addysnow1 Help Archive 0 07/10/2009 09:13 PM
How do i enable and disable commands? Coolman12 Help Archive 9 18/04/2009 10:47 AM


All times are GMT. The time now is 11:34 AM.


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