.:[HELP]:. [I debugged this command, what is wrong?]
#1

pawn Код:
if(strcmp(cmd, "/giveweaponlicense", true) == 0 || strcmp(cmd, "/gwl", true) == 0)
    {
    printf("<-[DEBUG]->: Passed GWL 1");
      giveplayerid = ReturnUser(tmp);
      printf("<-[DEBUG]->: Passed GWL 2");
      if(IsPlayerConnected(playerid))
        {
        printf("<-[DEBUG]->: Passed GWL 3");
            if (PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1)
            {
            printf("<-[DEBUG]->: Passed GWL 4");
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                printf("<-[DEBUG]->: Passed GWL 5");
            new Float:x, Float:y, Float:z;
            printf("<-[DEBUG]->: Passed GWL 6");
            GetPlayerPos(giveplayerid,x,y,z);
            printf("<-[DEBUG]->: Passed GWL 7");
                    if(PlayerInfo[playerid][pRank] < 2)
                    {
                    printf("<-[DEBUG]->: Passed GWL 8");
                    SendClientMessage(playerid, COLOR_GRAD1, " You need to be Rank 2 to give license!");
                      return 1;
                    }
            if(!PlayerToPoint(15, playerid, x, y, z))
                    {
                    printf("<-[DEBUG]->: Passed GWL 9");
              SendClientMessage(playerid, COLOR_GRAD1, " Player is not near you!");
              printf("<-[DEBUG]->: Passed GWL ");
              return 1;
            }
            if(PlayerInfo[giveplayerid][pGunLic] == 1)
                    {
                    printf("<-[DEBUG]->: Passed GWL 10");
              SendClientMessage(playerid, COLOR_GRAD1, " Player already haves weapon license.");
              printf("<-[DEBUG]->: Passed GWL 11");
              return 1;
            }
            printf("<-[DEBUG]->: Passed GWL 12");
            PlayerInfo[giveplayerid][pGunLic] = 1;
            printf("<-[DEBUG]->: Passed GWL 13");
                GetPlayerName(playerid, sendername, sizeof(sendername));
                printf("<-[DEBUG]->: Passed GWL 14");
                    format(string, sizeof(string), "* Officer %s gave you Weapons License.", sendername);
                    printf("<-[DEBUG]->: Passed GWL 15");
                    SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
                    printf("<-[DEBUG]->: Passed GWL 16");
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    printf("<-[DEBUG]->: Passed GWL 17");
                    format(string, sizeof(string), "* You gave Weapons License to %s.",giveplayerid);
                    printf("<-[DEBUG]->: Passed GWL 18");
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    printf("<-[DEBUG]->: Passed GWL 19");
          }
            }
            else
            {
            printf("<-[DEBUG]->: Passed GWL 20 FINAL!");
              SendClientMessage(playerid, COLOR_GRAD1, " You are not Cop!");
              return 1;
            }
        }
        return 1;
    }
It stops on "Passed GWL 4"
Reply
#2

Ask in the scripts thread!
Reply
#3

Quote:
Originally Posted by SaiBerFun
Ask in the scripts thread!
What the f?
Reply
#4

Add
Код:
printf("giveplayeris = %d", giveplayerid);
below the line
Код:
giveplayerid = ReturnUser(tmp);
and see if the ID you see is correct. I think the problem is with that.
Reply
#5

Quote:
Originally Posted by player007
Add
Код:
printf("giveplayeris = %d", giveplayerid);
below the line
Код:
giveplayerid = ReturnUser(tmp);
and see if the ID you see is correct. I think the problem is with that.
[00:37:11] <-[DEBUG]->: Passed GWL 1
[00:37:11] giveplayeris = 255
[00:37:11] <-[DEBUG]->: Passed GWL 2
[00:37:11] <-[DEBUG]->: Passed GWL 3
[00:37:11] <-[DEBUG]->: Passed GWL 4

Hmmmmm... ?
Reply
#6

Okay, the problem is with this:
Код:
giveplayerid = ReturnUser(tmp);
It doesn't return the user ID correctly.
(Because this check fails:
Код:
if(giveplayerid != INVALID_PLAYER_ID)
since giveplayerid is equal to INVALID_PLAYER_ID, which is 255.)
Reply
#7

Quote:
Originally Posted by player007
Okay, the problem is with this:
Код:
giveplayerid = ReturnUser(tmp);
It doesn't return the user ID correctly.
(Because this check fails:
Код:
if(giveplayerid != INVALID_PLAYER_ID)
since giveplayerid is equal to INVALID_PLAYER_ID, which is 255.)
i changed

if(giveplayerid != INVALID_PLAYER_ID)

to

if(giveplayerid == INVALID_PLAYER_ID)

Right?
Reply
#8

No that's not going to work. If the giveplayerid is invalid, it can't be used, you can't do anything for the not-existing player. Check the ReturnUser, because the problem originates from there (as it returns INVALID_PLAYER_ID)
Reply
#9

Quote:
Originally Posted by player007
No that's not going to work. If the giveplayerid is invalid, it can't be used, you can't do anything for the not-existing player. Check the ReturnUser, because the problem originates from there (as it returns INVALID_PLAYER_ID)
Can you suggest anything please?

I have no clue what should i do..
Reply
#10

You aren't defining tmp, it still uses a value that has been set before

pawn Код:
if(strcmp(cmd, "/giveweaponlicense", true) == 0 || strcmp(cmd, "/gwl", true) == 0)
{
tmp = strtok(cmdtext, idx);
I do hope your script already uses strtok, if not you'll have to search for it somewhere..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)