Adminscript
#1

Im making an adminscript but if i login in rcon and do /givepilot i give myself pilot. I want have that /givepilot [ID] works.
Anyone know how i make /givepilot [ID] ?
Код:
  public OnPlayerCommandText(playerid, cmdtext[])

	if(strcmp("/makepilot", cmdtext, true) == 0)
  {
   if(IsPlayerAdmin(playerid))
{
    SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
    SetPlayerSkin(playerid, 61);
    IsPlayerAdmin(playerid);
    return 1;
}
return 1;
  }
Reply
#2

Hmm since I'm newbie scripter and we have faster commands like dcmd and zcmd, i can do this, but strtok...nope .

DCMD:

pawn Код:
dcmd_makepilot(playerid, params[])
{
new otherid;
if sscanf(params, "u", otherid) return SendClientMessage(playerid, COLOR_GREY, "USAGE: makepilot: ID");

if (!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, COLOR_GREY, "You must be admin!");

SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
SetPlayerSkin(playerid, 61);
return 1;
}
Reply
#3

Quote:
Originally Posted by wiilweer
Hmm since I'm newbie scripter and we have faster commands like dcmd and zcmd, i can do this, but strtok...nope .

DCMD:

pawn Код:
dcmd_makepilot(playerid, params[])
{
new otherid;
if sscanf(params, "u", otherid) return SendClientMessage(playerid, COLOR_GREY, "USAGE: makepilot: ID");

if (!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, COLOR_GREY, "You must be admin!");

SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
SetPlayerSkin(playerid, 61);
return 1;
}
Not works, standing ingame: Unknown Command
Reply
#4

Anyone else?
Reply
#5

Quote:
Originally Posted by icorne
Anyone else?
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new idx;
  new cmd[256];
  cmd = strtok(cmdtext, idx);
  if(!strcmp("/makepilot", cmd, true))
  {
    if(IsPlayerAdmin(playerid))
        {
        new tmp[128];
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)){
                SendClientMessage(playerid,0xFF6600AA,"USAGE: /makepilot [playerid]");
                return true;
            }

        new pid = strval(tmp);
        if(!IsPlayerConnected(pid)){
          SendClientMessage(playerid,0xFF6600AA,"Player is offline");
                return true;
        }
        SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
        SendClientMessage(pid, 0xFF6600AA, "You're now a pilot!");
        SetPlayerSkin(pid, 61);
        return 1;
        }
    }
    return 1;
}
In case you need:

pawn Код:
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;
}
Reply
#6

Quote:
Originally Posted by wafffllesss
Quote:
Originally Posted by icorne
Anyone else?
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new idx;
  new cmd[256];
  cmd = strtok(cmdtext, idx);
  if(!strcmp("/makepilot", cmd, true))
  {
    if(IsPlayerAdmin(playerid))
        {
        new tmp[128];
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)){
                SendClientMessage(playerid,0xFF6600AA,"USAGE: /makepilot [playerid]");
                return true;
            }

        new pid = strval(tmp);
        if(!IsPlayerConnected(pid)){
          SendClientMessage(playerid,0xFF6600AA,"Player is offline");
                return true;
        }
        SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
        SendClientMessage(pid, 0xFF6600AA, "You're now a pilot!");
        SetPlayerSkin(pid, 61);
        return 1;
        }
    }
    return 1;
}
In case you need:

pawn Код:
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;
}
Good but 1 error: C:\Documents and Settings\Administrator\Bureaublad\Warserver\filter scripts\admscript.pwn(42) : error 030: compound statement not closed at the end of file (started at line 15)
Reply
#7

Quote:
Originally Posted by icorne
Quote:
Originally Posted by wafffllesss
Quote:
Originally Posted by icorne
Anyone else?
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new idx;
  new cmd[256];
  cmd = strtok(cmdtext, idx);
  if(!strcmp("/makepilot", cmd, true))
  {
    if(IsPlayerAdmin(playerid))
        {
        new tmp[128];
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)){
                SendClientMessage(playerid,0xFF6600AA,"USAGE: /makepilot [playerid]");
                return true;
            }

        new pid = strval(tmp);
        if(!IsPlayerConnected(pid)){
          SendClientMessage(playerid,0xFF6600AA,"Player is offline");
                return true;
        }
        SendClientMessage(playerid, 0xFF6600AA, "That player is now pilot!");
        SendClientMessage(pid, 0xFF6600AA, "You're now a pilot!");
        SetPlayerSkin(pid, 61);
        return 1;
        }
    }
    return 1;
}
In case you need:

pawn Код:
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;
}
Good but 1 error: C:\Documents and Settings\Administrator\Bureaublad\Warserver\filter scripts\admscript.pwn(42) : error 030: compound statement not closed at the end of file (started at line 15)
This mean you forget to close "}" something.. cuz the script i set you is working. at least for me. check your script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)