Hopeless I need an uregent help.
#1

I was working again on this irritating script, "Ajail" and it doesn't show the reason for the Ajail, and the time, it shows me 0 minutes all the time, on the message to all.
pawn Код:
if(strcmp(cmd, "/ajail", true) == 0)
    {
     if(IsPlayerConnected(playerid))
        {
    tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [PlayerID/PartOfName] [Time(minutes)] [Reason]");
                return 1;
            }
            new playa;
        new jailReason[128];
                    new JailTime;
            new money;
            playa = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            money = strval(tmp);
            if (PlayerInfo[playerid][pAdmin] >= 1)
            {
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        format(string, sizeof(string), "* You Jailed %s.", giveplayer);
                        SendClientMessage(playerid, COLOR_LIGHTRED, string);

                        ResetPlayerWeapons(playa);
                        WantedPoints[playa] = 0;
                        PlayerInfo[playa][pJailed] = 1;
                        PlayerInfo[playa][pJailTime] = money*60;

        SetPlayerPos(playa,1769.37341309,178.79183960,1369.28161621);

     GetPlayerName(playerid, sendername, sizeof(sendername));
  format(string, sizeof(string), "%s was admin jailed by %s for %d minutes, Reason: %s ",giveplayer, sendername, JailTime, jailReason);
       BroadCast(0xFF4646FF,string);

    }

                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
            }
        }
        return 1;
    }
Reply
#2

Anyone please.
Reply
#3

Don't double post, you can only do that after 12 hours.
Reply
#4

Instead could not you post some feedback ? .
Can anyone help, I really need help, I have been trying it since yesterday.
Reply
#5

You declared 'JailTime', but you haven't assigned it a value anywhere. The variable (I assume) should contain your 'JailTime' value is 'money', remove 'new JailTime;' and change your format to:

pawn Код:
format(string, sizeof(string), "%s was admin jailed by %s for %d minutes, Reason: %s ",giveplayer, sendername, money, jailReason);
All I see is you posting for scripting help, why don't you try actually script yourself instead of relying on everyone else to fix your script problems?... Unless you're actually that incompetent.
Reply
#6

You are not getting the 'Jailtime' or 'reason' variable from the commandtext.
also you have repeated getplayername for sendername.
pawn Код:
if(!strcmp(cmd,"/ajail",true))
{
     if (PlayerInfo[playerid][pAdmin] >= 1)
     {  
          tmp = strtok(cmdtext, idx);
          if(!strlen(tmp))
          {
             ...
          }
          new playa = ReturnUser(tmp);
          if(playa != INVALID_PLAYER_ID)
          {
              tmp = strtok(cmdtext, idx);
              new jailtime = strval(tmp);
              if(jailtime < 1 || jailtime > 3600)
             {
                 ...
              }
              new length = strlen(cmdtext);
              while ((idx < length) && (cmdtext[idx] <= ' '))
              {
                     idx++;
              }
              new offset = idx;
              new result[64];
              while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
              {
                   result[idx - offset] = cmdtext[idx];
                   idx++;
               }
               result[idx - offset] = EOS;
               if(!strlen(result))  
               {
                  ....
               }
                GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                // you can insert the rest of the script in here
                format(string, sizeof(string), "%s was admin jailed by %s for %d minutes, Reason: %s ",giveplayer, sendername, jailtime, result);
untested, but you should be able to get this to work
Reply
#7

Worked, but It doesn't show the reason, can you help me with that .
BTW, I made that code, I know how to script, but I ran into some issues, and by asking your help, I'm getting better.
Reply
#8

Quote:
Originally Posted by Rachael
Посмотреть сообщение
You are not getting the 'Jailtime' or 'reason' variable from the commandtext.
also you have repeated getplayername for sendername.
pawn Код:
if(!strcmp(cmd,"/ajail",true))
{
     if (PlayerInfo[playerid][pAdmin] >= 1)
     {  
          tmp = strtok(cmdtext, idx);
          if(!strlen(tmp))
          {
             ...
          }
          new playa = ReturnUser(tmp);
          if(playa != INVALID_PLAYER_ID)
          {
              tmp = strtok(cmdtext, idx);
              new jailtime = strval(tmp);
              if(jailtime < 1 || jailtime > 3600)
             {
                 ...
              }
              new length = strlen(cmdtext);
              while ((idx < length) && (cmdtext[idx] <= ' '))
              {
                     idx++;
              }
              new offset = idx;
              new result[64];
              while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
              {
                   result[idx - offset] = cmdtext[idx];
                   idx++;
               }
               result[idx - offset] = EOS;
               if(!strlen(result))  
               {
                  ....
               }
                GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                // you can insert the rest of the script in here
                format(string, sizeof(string), "%s was admin jailed by %s for %d minutes, Reason: %s ",giveplayer, sendername, jailtime, result);
untested, but you should be able to get this to work
That is a horrible way to code - do not use this!
Reply
#9

Didn't test her code, but can you help me ?
I still don't see the stated reason for the Ajail, when I ajail It doesn't show the reason.
Reply
#10

hello my internet name is realcop and all I can do is offer criticism.

scriptissue: you could use sscanf2 and zcmd, and then this would be a lot easier, but if you are determined to use strtok, you should at least try the code I suggested. If the 'reason' for the ajail is going to be more than one word, then you can't use strtok to get it. The code I showed you will do it, but apparantly it is inferior.

you could also use strmid to get the reason from cmdtext
pawn Код:
strmid(jailreason,cmdtext,idx,strlen(cmdtext),sizeof(jailreason));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)