Making a /setsdoor
#1

How do i make it so that in order to do the command /osdoor qne /csdoor you have to be set by someone using the command /setsdoor id
so for example
if i wasnt set and i did /osdoor i would get You are not allowed to use this command
same for /csdoor
but if i did /setsdoor id i would be able to do it

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/osdoor", true) == 0)
    {
        MoveObject(sdoor, 2974.106445,2124.700683,8.532794, 1.500000);
        MoveObject(radar, 2965.032226,2123.313232,8.486142,1.500000);
        MoveObject(stairs, 2966.623046,2116.100097,6.840229,1.500000);
        return 1;
    }
    if(strcmp(cmdtext,"/csdoor", true) == 0)
    {
        MoveObject(sdoor, 2974.106445,2116.620117,8.532794, 1.500000);
        MoveObject(radar, 2966.035156,2118.921875,8.486142, 1.500000);
        MoveObject(stairs, 2966.623046,2116.100097,2.008096,1.500000);
        return 1;
    }
Reply
#2

pawn Код:
//on top
new CanUseDoor[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/osdoor", true) == 0 && CanUseDoor[playerid] == 1)
    {
        MoveObject(sdoor, 2974.106445,2124.700683,8.532794, 1.500000);
        MoveObject(radar, 2965.032226,2123.313232,8.486142,1.500000);
        MoveObject(stairs, 2966.623046,2116.100097,6.840229,1.500000);
        return 1;
    }
    if(strcmp(cmdtext,"/csdoor", true) == 0 && CanUseDoor[playerid] == 1)
    {
        MoveObject(sdoor, 2974.106445,2116.620117,8.532794, 1.500000);
        MoveObject(radar, 2966.035156,2118.921875,8.486142, 1.500000);
        MoveObject(stairs, 2966.623046,2116.100097,2.008096,1.500000);
        return 1;
    }
    if(strcmp(cmdtext,"/setsdoor",true)==0)
    {
          if(!IsPlayerAdmin(playerid)) return 0;
          if(!strlen(cmdtext[10])) return SendClientMessage(playerid,0xFFFFFFFF,"Usage: /setsdoor [playerid]");
          new gplayerid = strval(cmdtext[10]);
          if(IsPlayerConnected(gplayerid))
          {
                 if(CanUseDoor[playerid] == 0)  CanUseDoor[playerid] = 1;
                 else CanUseDoor[playerid] = 0;
                 return 1;
          }
     }
     return 0;
}

OnPlayerConnect(playerid)
{
      CanUseDoor[playerid] = 0;
}
You mean like this? (correct me if I'm wrong)

Also you need to be logged in as admin (in rcon) to use /setsdoor
Reply
#3

Im getting unknown command when i do /setsdoor id
Reply
#4

Quote:
Originally Posted by Jack-
Посмотреть сообщение
Im getting unknown command when i do /setsdoor id
are you logged in as admin?
Reply
#5

yes but im using the the core lvdm logged into rcon
Reply
#6

What does it return if you just type '/setsdoor'
Reply
#7

it says usage /setsdoor id
Reply
#8

pawn Код:
//on top
new CanUseDoor[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/osdoor", true) == 0 && CanUseDoor[playerid] == 1)
    {
        MoveObject(sdoor, 2974.106445,2124.700683,8.532794, 1.500000);
        MoveObject(radar, 2965.032226,2123.313232,8.486142,1.500000);
        MoveObject(stairs, 2966.623046,2116.100097,6.840229,1.500000);
        return 1;
    }
    if(strcmp(cmdtext,"/csdoor", true) == 0 && CanUseDoor[playerid] == 1)
    {
        MoveObject(sdoor, 2974.106445,2116.620117,8.532794, 1.500000);
        MoveObject(radar, 2966.035156,2118.921875,8.486142, 1.500000);
        MoveObject(stairs, 2966.623046,2116.100097,2.008096,1.500000);
        return 1;
    }
    if(strcmp(cmdtext,"/setsdoor",true)==0)
    {
          if(!IsPlayerAdmin(playerid)) return 0;
          if(!strlen(cmdtext[10])) return SendClientMessage(playerid,0xFFFFFFFF,"Usage: /setsdoor [playerid]");
          new gplayerid = strval(cmdtext[10]);
          if(IsPlayerConnected(gplayerid))
          {
                 if(CanUseDoor[gplayerid] == 0)  CanUseDoor[gplayerid] = 1; // make gplayerid from playerid
                 else CanUseDoor[gplayerid] = 0;
                 return 1;
          }
          else return SendClientMessage(playerid,0xFFFFFFFF,"Player not connected");
     }
     return 0;
}

OnPlayerConnect(playerid)
{
      CanUseDoor[playerid] = 0;
}
I found a little error in my script but that still isn't going to fix your problem:

don't insert part of name, really insert a number like:
Код:
 /setsdoor 0
Anyway, modify what I just modified and update me.
Reply
#9

thats what i do
Reply
#10

pawn Код:
//on top
new CanUseDoor[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/osdoor", true) == 0 && CanUseDoor[playerid] == 1)
    {
        MoveObject(sdoor, 2974.106445,2124.700683,8.532794, 1.500000);
        MoveObject(radar, 2965.032226,2123.313232,8.486142,1.500000);
        MoveObject(stairs, 2966.623046,2116.100097,6.840229,1.500000);
        return 1;
    }
    if(strcmp(cmdtext,"/csdoor", true) == 0 && CanUseDoor[playerid] == 1)
    {
        MoveObject(sdoor, 2974.106445,2116.620117,8.532794, 1.500000);
        MoveObject(radar, 2966.035156,2118.921875,8.486142, 1.500000);
        MoveObject(stairs, 2966.623046,2116.100097,2.008096,1.500000);
        return 1;
    }
    if(strcmp(cmdtext,"/setsdoor",true)==0)
    {
          if(!IsPlayerAdmin(playerid)) return 0;
          new str[32], idx;
          str = strtok(cmdtext,idx);
          if(!strlen(str)) return SendClientMessage(playerid,0xFFFFFFFF,"Usage: /setsdoor [playerid]");
          new gplayerid = strval(str);
          if(IsPlayerConnected(gplayerid))
          {
                 if(CanUseDoor[gplayerid] == 0)  CanUseDoor[gplayerid] = 1; // make gplayerid from playerid
                 else CanUseDoor[gplayerid] = 0;
                 return 1;
          }
          else return SendClientMessage(playerid,0xFFFFFFFF,"Player not connected");
     }
     return 0;
}

OnPlayerConnect(playerid)
{
      CanUseDoor[playerid] = 0;
}

//if you dont already have this defined...
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
ok this is an alternative. try it and update me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)