PDA

View Full Version : OnPlayerCommandText


Ghazal
17/04/2014, 03:25 PM
Hello,
So i have added this under OnPlayerCommandText

if(Minigames[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"You cant use commands now."), 0;

And its working fine

But i got a question .. I want to enable just one command When player is in minigames

Help please.

offon
17/04/2014, 03:41 PM
Define a variable and use it to check if the player is in the minigame.

HitterHitman
17/04/2014, 03:43 PM
Then add that command above the line. I believe it will work.

Gaurav_Rawat
17/04/2014, 03:44 PM
While creating your command
use the variable
CMD:balbla(playerid,params[])
{
if(Minigames[playerid] == 1)
{
Your things
}
return 1;
}

Hanuman
17/04/2014, 03:47 PM
Just try to put ur command above that line

//your command
if(Minigames[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"You cant use commands now."), 0;

Bingo
17/04/2014, 03:48 PM
http://forum.sa-mp.com/showthread.php?t=507362

I explained you right?

dcmd_command(playerid,params[])
{
if(Minigames[playerid] == 1)
{
SendClientMessage........
//goes your stuff
}
return 1;
}

offon
17/04/2014, 03:48 PM
@Gaurav: I'm not sure if I understood him, but he wants to disable all commands and make only one work. If it's the case your code won't help him. If not, I'm sorry for disturbing.

nGen.SoNNy
17/04/2014, 03:49 PM
Example :)


if( Minigames[playerid] == 1 )
{
if( !strcmp( cmdtext, "/leave", true ) || !strcmp( cmdtext, "/siren", true ) || !strcmp( cmdtext, "/cnrfix", true ) || !strcmp( cmdtext, "/unar", true ) || !strcmp( cmdtext, "/nb", true ) || !strcmp( cmdtext, "/tpm", true ) || !strcmp( cmdtext, "/cnrhelp", true ) || !strcmp( cmdtext, "/cnrtop", true ) || !strcmp( cmdtext, "/rob", true ) || !strcmp( cmdtext, "/ar", true ) || !strcmp( cmdtext, "/hideme", true ) ) return ( 1 );
switch( PlayerInfo[ playerid ][ Lang ] )
{
case 0: Announce( playerid, "~y~~h~~h~Use ~r~~h~/leave ~y~~h~~h~for exit.", 3000, 4 );
case 1: Announce( playerid, "~y~~h~~h~Scrie ~r~~h~/leave ~y~~h~~h~ca sa iesi.", 3000, 4 );
}
return ( 0 );
}

Ghazal
17/04/2014, 03:49 PM
http://forum.sa-mp.com/showthread.php?t=507362

I explained you right?

dcmd_command(playerid,params[])
{
if(Minigames[playerid] == 1)
{
SendClientMessage........
//goes your stuff
}
return 1;
}

Dude, Will i just add that if in 200 command? lol.

Hanuman
17/04/2014, 03:51 PM
Example :)


if( Minigames[playerid] == 1 )
{
if( !strcmp( cmdtext, "/leave", true ) || !strcmp( cmdtext, "/siren", true ) || !strcmp( cmdtext, "/cnrfix", true ) || !strcmp( cmdtext, "/unar", true ) || !strcmp( cmdtext, "/nb", true ) || !strcmp( cmdtext, "/tpm", true ) || !strcmp( cmdtext, "/cnrhelp", true ) || !strcmp( cmdtext, "/cnrtop", true ) || !strcmp( cmdtext, "/rob", true ) || !strcmp( cmdtext, "/ar", true ) || !strcmp( cmdtext, "/hideme", true ) ) return ( 1 );
switch( PlayerInfo[ playerid ][ Lang ] )
{
case 0: Announce( playerid, "~y~~h~~h~Use ~r~~h~/leave ~y~~h~~h~for exit.", 3000, 4 );
case 1: Announce( playerid, "~y~~h~~h~Scrie ~r~~h~/leave ~y~~h~~h~ca sa iesi.", 3000, 4 );
}
return ( 0 );
}

Is that he want?

Bingo
17/04/2014, 03:51 PM
Dude, Will i just add that if in 200 command? lol.

You stated above only 'one' cmd, So which cmd you want that players can use while in minigames you've to add :-).

HitterHitman
17/04/2014, 03:51 PM
Add the one command above the line it will work.

Hanuman
17/04/2014, 03:53 PM
http://forum.sa-mp.com/showthread.php?t=507362

I explained you right?

dcmd_command(playerid,params[])
{
if(Minigames[playerid] == 1)
{
SendClientMessage........
//goes your stuff
}
return 1;
}
I think Bingo has forgotten to add "||Minigames[playerid] == 0" bcoz he need's that the player can use his command inside minigame as well as outside minigame.

From Bingo codes u should do it like this.

dcmd_command(playerid,params[])
{
if(Minigames[playerid] == 1 || Minigames[playerid] == 0)
{
SendClientMessage........
//goes your stuff
}
return 1;
}

Ghazal
17/04/2014, 03:58 PM
Example :)


if( Minigames[playerid] == 1 )
{
if( !strcmp( cmdtext, "/leave", true ) || !strcmp( cmdtext, "/siren", true ) || !strcmp( cmdtext, "/cnrfix", true ) || !strcmp( cmdtext, "/unar", true ) || !strcmp( cmdtext, "/nb", true ) || !strcmp( cmdtext, "/tpm", true ) || !strcmp( cmdtext, "/cnrhelp", true ) || !strcmp( cmdtext, "/cnrtop", true ) || !strcmp( cmdtext, "/rob", true ) || !strcmp( cmdtext, "/ar", true ) || !strcmp( cmdtext, "/hideme", true ) ) return ( 1 );
switch( PlayerInfo[ playerid ][ Lang ] )
{
case 0: Announce( playerid, "~y~~h~~h~Use ~r~~h~/leave ~y~~h~~h~for exit.", 3000, 4 );
case 1: Announce( playerid, "~y~~h~~h~Scrie ~r~~h~/leave ~y~~h~~h~ca sa iesi.", 3000, 4 );
}
return ( 0 );
}

I edited it to :
if( Minigames[playerid] == 1 )
{
if(dcmd_exit(playerid,params[])) return ( 1 );
SendClientMessage(playerid,COLOR_RED,"You cant use commands now, use /exit to leave minigame and use commands!");
return ( 0 );
}
And now there is one error ..
Undefined symbol params

Bingo
17/04/2014, 03:58 PM
I think Bingo has forgotten to add "||Minigames[playerid] == 0" bcoz he need's that the player can use his command inside minigame as well as outside minigame.

From Bingo codes u should do it like this.

dcmd_command(playerid,params[])
{
if(Minigames[playerid] == 1 || Minigames[playerid] == 0)
{
SendClientMessage........
//goes your stuff
}
return 1;
}


if(Minigames[playerid] == 1 - If player in minigame
Minigames[playerid] == 0) - If player not in minigame

So he wants some commands to be utilizied inside minigame so this (if(Minigames[playerid] == 1).