Help with /leavedm command
#1

The script that I use:My DM
Description of the problem:Can anyone give me an example of how to create a command that player who enter my islanddeathmatch cant type any command like /vehicle /weapons and other only can chat ...Then when he type /leavedm he get out..I make simple /leavedm but dont know how to make checking whether there is command if so, when the command to kick him out, and if not in deathmatch could not use the command.
Sorry for bad english,not my basic lang.. :S
Part of script(islanddm command):

Код:
CMD:islanddm(playerid, params[])
{
	new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	SetTimerEx("Unfreeze", 2000, 0, "d", playerid);
   	GameTextForPlayer(playerid,"~g~Waiting for the Objects to load",2000,3);
    format(string, sizeof(string), "{FF0000}(/islanddm) {FFFF00}Player {FF0000}%s {FFFF00}has Teleported to {FF0000}Island DeathMatch",pName);
    SendClientMessageToAll(playerid, string);
    new Random = random(sizeof(RandomSpawnIslandDM));
    SetPlayerPos(playerid, RandomSpawnIslandDM[Random][0], RandomSpawnIslandDM[Random][1], RandomSpawnIslandDM[Random][2]);
}
Part of script(leave command):

Код:
CMD:leavedm(playerid, params[])
{
    new Random = random(sizeof(RandomSpawnLEAVEDM));
    SetPlayerPos(playerid, RandomSpawnLEAVEDM[Random][0], RandomSpawnLEAVEDM[Random][1], RandomSpawnLEAVEDM[Random][2]); // Place the X Y Z of the position where they player will be when they type this command
    SendClientMessage(playerid, COLOR_RED, "You have left the Deathmatch Area");
    return 1;
}
Reply
#2

You could do it by creating variables.

pawn Код:
new InDM[MAX_PLAYERS]; //Creating a player variable to use it to detect in dm or not.

CMD:islanddm(playerid, params[])
{
    new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    SetTimerEx("Unfreeze", 2000, 0, "d", playerid);
    GameTextForPlayer(playerid,"~g~Waiting for the Objects to load",2000,3);
    format(string, sizeof(string), "{FF0000}(/islanddm) {FFFF00}Player {FF0000}%s {FFFF00}has Teleported to {FF0000}Island DeathMatch",pName);
    SendClientMessageToAll(playerid, string);
    new Random = random(sizeof(RandomSpawnIslandDM));
    SetPlayerPos(playerid, RandomSpawnIslandDM[Random][0], RandomSpawnIslandDM[Random][1], RandomSpawnIslandDM[Random][2]);
    InDM[playerid] = 1; //Sets the variable of dm to 1 so we can use that player has entered dm.
    return 1;
}

CMD:leavedm(playerid, params[])
{
   if(InDM[playerid] == 1) //If the dm variable is 1, which means player is in dm.
   { //If yes,
    new Random = random(sizeof(RandomSpawnLEAVEDM));
    SetPlayerPos(playerid, RandomSpawnLEAVEDM[Random][0], RandomSpawnLEAVEDM[Random][1], RandomSpawnLEAVEDM[Random][2]); // Place the X Y Z of the position where they player will be when they type this command
    SendClientMessage(playerid, COLOR_RED, "You have left the Deathmatch Area");
     InDM[playerid] = 0; //Setting to 0 to make that player has left dm.
   }
  else //If not,
  {
     SendClientMessage(playerid, 0xFF0000FF, "You are not in a dm to use this command.");
   }
    return 1;
}
Like this you can.
Reply
#3

Define this globally, anywhere after the includes lines:

pawn Код:
new IsInIsland[MAX_PLAYERS];
And make a specific value set for the variable if the player in the island, and to be changed when leaving.

pawn Код:
CMD:islanddm(playerid, params[])
{
    if(IsInIsland[playerid]) return SendClientMessage(playerid, COLOR_RED,"You are already at the island!");
    new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    SetTimerEx("Unfreeze", 2000, 0, "d", playerid);
    GameTextForPlayer(playerid,"~g~Waiting for the Objects to load",2000,3);
    format(string, sizeof(string), "{FF0000}(/islanddm) {FFFF00}Player {FF0000}%s {FFFF00}has Teleported to {FF0000}Island DeathMatch",pName);
    SendClientMessageToAll(playerid, string);
    new Random = random(sizeof(RandomSpawnIslandDM));
    SetPlayerPos(playerid, RandomSpawnIslandDM[Random][0], RandomSpawnIslandDM[Random][1], RandomSpawnIslandDM[Random][2]);
    IsInIsland[playerid] = 1;
}

CMD:leavedm(playerid, params[])
{
    if(!IsInIsland[playerid]) return SendClientMessage(playerid, COLOR_RED,"You are not at the island - /islanddm to join!");
    new Random = random(sizeof(RandomSpawnLEAVEDM));
    SetPlayerPos(playerid, RandomSpawnLEAVEDM[Random][0], RandomSpawnLEAVEDM[Random][1], RandomSpawnLEAVEDM[Random][2]); // Place the X Y Z of the position where they player will be when they type this command
    SendClientMessage(playerid, COLOR_RED, "You have left the Deathmatch Area");
    IsInIsland[playerid] = 1;
    return 1;
}
And for the checking for the commands you want to use when only at the island make it like the example stated when joining.
Reply
#4

EDIT: Wait for testing,And edit when finish
Reply
#5

Just add "return 1;" after the variable "IsInIsland[playerid] = 1;" in the joining command, and my bad, make the second one when leaving to be "IsInIsland[playerid] = 0;".
Reply
#6

Quote:
Originally Posted by Randy More
Посмотреть сообщение
Just add "return 1;" after the variable "IsInIsland[playerid] = 1;" in the joining command, and my bad, make the second when when leaving to be "IsInIsland[playerid] = 0;".
I gonna test in 2 min
Reply
#7

Remove this post -.- internet connection
Reply
#8

Yes, as i told you, make the second "IsInIsland.." to give 0 value now 1, i made it 1 by mistake.

pawn Код:
CMD:leavedm(playerid, params[])
{
    if(!IsInIsland[playerid]) return SendClientMessage(playerid, COLOR_RED,"You are not at the island - /islanddm to join!");
    new Random = random(sizeof(RandomSpawnLEAVEDM));
    SetPlayerPos(playerid, RandomSpawnLEAVEDM[Random][0], RandomSpawnLEAVEDM[Random][1], RandomSpawnLEAVEDM[Random][2]); // Place the X Y Z of the position where they player will be when they type this command
    SendClientMessage(playerid, COLOR_RED, "You have left the Deathmatch Area");
    IsInIsland[playerid] = 0;
    return 1;
}
Reply
#9

Thanks,works,can u tell me how to make when he leave he get his skin back..And when he are in deathmatch he cant use command like /vehicle and all other only can use chat ? Rep+ to you and Lordz
Reply
#10

pawn Код:
// Create this variable under the IsInIsland one.
new Skin[MAX_PLAYERS];

CMD:islanddm(playerid, params[])
{
    if(IsInIsland[playerid]) return SendClientMessage(playerid, COLOR_RED,"You are already at the island!");
    new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
     Skin[playerid] = GetPlayerSkin(playerid);
    SetTimerEx("Unfreeze", 2000, 0, "d", playerid);
    GameTextForPlayer(playerid,"~g~Waiting for the Objects to load",2000,3);
    format(string, sizeof(string), "{FF0000}(/islanddm) {FFFF00}Player {FF0000}%s {FFFF00}has Teleported to {FF0000}Island DeathMatch",pName);
    SendClientMessageToAll(playerid, string);
    new Random = random(sizeof(RandomSpawnIslandDM));
    SetPlayerPos(playerid, RandomSpawnIslandDM[Random][0], RandomSpawnIslandDM[Random][1], RandomSpawnIslandDM[Random][2]);
    IsInIsland[playerid] = 1;
    return 1;
}

CMD:leavedm(playerid, params[])
{
    if(!IsInIsland[playerid]) return SendClientMessage(playerid, COLOR_RED,"You are not at the island - /islanddm to join!");
    new Random = random(sizeof(RandomSpawnLEAVEDM));
    SetPlayerPos(playerid, RandomSpawnLEAVEDM[Random][0], RandomSpawnLEAVEDM[Random][1], RandomSpawnLEAVEDM[Random][2]); // Place the X Y Z of the position where they player will be when they type this command
    SendClientMessage(playerid, COLOR_RED, "You have left the Deathmatch Area");
    IsInIsland[playerid] = 0;
    SetPlayerSkin(playerid, Skin[playerid]);
    return 1;
}

// An example of making a restricted command that only works if not in the island.

CMD:vehicle(playerid, params[])
{
     if(IsInIsland[playerid]) return SendClientMessage(playerid, COLOR_RED,"You can
t use this command while in the island!"
);
    // Your code if he is not.
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)