not spawed
#1

players are typing a cmd when they arent even spawned!!

How can I disable that And make something like.

"Please spawn before typing a command"

And you disable the cmds.
Reply
#2

Use booleans ...
Reply
#3

Can you give me an example? il rep you dw.

Im new into scripting.
Reply
#4

pawn Код:
new bool:Commands[MAX_PLAYERS];

//OnPlayerConnect
Commands[playerid] = false;

//OnPlayerSpawn
Commands[playerid] = true;

//OnPlayerCommandText
if(!Commands[playerid])
    return SendClientMessage(playerid,-1,"Please spawn before typing a command");
Reply
#5

use IsPlayerLoggedIn on the commands, if you have a login/register system
Reply
#6

pawn Код:
new bool:isspawned[MAX_PLAYERS]; //Create a variable that stores whether the player is spawned or not.
pawn Код:
OnPlayerCommandText(playerid, cmdtext[])
{
  if(isspawned[playerid]) //Is the player spawned?
  {
     //commands
     return 1;
  }
  else return SendClientMessage(playerid, 0xFFFFFFAA, "Please spawn before using this command."); //Return that the player has to spawn if not.
}
pawn Код:
OnPlayerSpawn(playerid)
{
  isspawned[playerid] = true; //If the player spawns, the value is set to true.
  return 1;
}

OnPlayerDeath(playerid)
{
  isspawned[playerid] = false; //If the player dies/despawn, the value is set to false.
  return 1;
}

OnPlayerDisconnect(playerid, reason)
{
  isspawned[playerid] = false; //If the player dies/despawn, the value is set to false.
  return 1;
}
Should give you some idea of what to do.
Reply
#7

pawn Код:
new CanUseCommands [ MAX_PLAYERS ] = 0;
OnPlayerConnect:

pawn Код:
CanUseCommands [ playerid ] = 0;
OnPlayerCommandText:
pawn Код:
if( CanUseCommands [ playerid ] != 1 ) return false; // Put the rest of your commands under it!
OnPlayerDeath:
pawn Код:
CanUseCommands[ playerid ] = 0;
OnPlayerSpawn:
pawn Код:
CanUseCommands [ playerid ] = 1;
Edit: Beat me to it.
Reply
#8

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
pawn Код:
new bool:Commands[MAX_PLAYERS];

//OnPlayerConnect
Commands[playerid] = false;

//OnPlayerSpawn
Commands[playerid] = true;

//OnPlayerCommandText
if(!Commands[playerid])
    return SendClientMessage(playerid,-1,"Please spawn before typing a command");
rep you thanks worked.
Reply
#9

They still can talk not a command but still can talk when not spawned.
Reply
#10

Quote:
Originally Posted by 2KY
Посмотреть сообщение
pawn Код:
new CanUseCommands [ MAX_PLAYERS ] = 0;
OnPlayerConnect:

pawn Код:
CanUseCommands [ playerid ] = 0;
OnPlayerCommandText:
pawn Код:
if( CanUseCommands [ playerid ] != 1 ) return false; // Put the rest of your commands under it!
OnPlayerDeath:
pawn Код:
CanUseCommands[ playerid ] = 0;
OnPlayerSpawn:
pawn Код:
CanUseCommands [ playerid ] = 1;
Edit: Beat me to it.
Thanks for helping me rep u.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)