DestroyVehicle problem
#1

pawn Код:
if(strcmp(cmdtext, "/delveh", true) == 0)
     {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /delveh");
                return 1;
            }
            if (PlayerInfo[playerid][pAdmin] >=2)
            {
                    new currentveh;
                    currentveh = GetPlayerVehicleID(playerid);
                    DestroyVehicle(currentveh);
             }
                    else SendClientMessage(playerid, COLOR_RED,"You're not admin!");
            {
                format(string, sizeof(string), "*%d Admin %s: Deleted the vehicle", PlayerInfo[playerid][pAdmin], sendername);
                SendAdminMessage(COLOR_YELLOW,string);
            }
            printf("Admin %s: Deleted the vehicle", sendername);
            SendClientMessage(playerid, COLOR_GRAD1,"Vehicle deleted!");
        }
        return 1;
     }
There aren't any errors or warnings in pawno. The command just doesn't work. Can someone fix this code and please explain me what I did wrong?
Thanks :P
Reply
#2

Your command was a little messy and else statement smack in the middle made the command stop processing.

You should add your else statement at the end of everything like so.

So move this
pawn Код:
else SendClientMessage(playerid, COLOR_RED,"You're not admin!");
at the end of the command, so it should look like this.
pawn Код:
if(strcmp(cmdtext, "/delveh", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /delveh");
            return 1;
        }
        if (PlayerInfo[playerid][pAdmin] >=2)
        {
            new currentveh;
            currentveh = GetPlayerVehicleID(playerid);
            DestroyVehicle(currentveh);
            format(string, sizeof(string), "*%d Admin %s: Deleted the vehicle", PlayerInfo[playerid][pAdmin], sendername);
            SendAdminMessage(COLOR_YELLOW,string);
            printf("Admin %s: Deleted the vehicle", sendername);
            SendClientMessage(playerid, COLOR_GRAD1,"Vehicle deleted!");
            return 1;
        }
        else
        {
            return SendClientMessage(playerid, COLOR_RED,"You're not admin!");
        }
    }
    return 1;
}
Reply
#3

You lack a "return 1" somewhere. Wont tell you where, just find it out. Not hard.
Reply
#4

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
You lack a "return 1" somewhere. Wont tell you where, just find it out. Not hard.
I don't believe there is, btw if you won't help then don't post man lmao. :P
Reply
#5

Quote:
Originally Posted by Walsh
Посмотреть сообщение
I don't believe there is, btw if you won't help then don't post man lmao. :P
You are wrong. My post is the one that helps. If i make thhe code for you, you just copy/paste instead of work to fix your own errors. That's how i've learn. Try it.. If doesnn't work, just tell.

But ok.. Here you go, not tested, made almost sleeping, hope it works.

pawn Код:
if(strcmp(cmdtext, "/delveh", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /delveh");
            return 1;
        }
        if (PlayerInfo[playerid][pAdmin] >=2)
        {
            new currentveh = GetPlayerVehicleID(playerid);
            DestroyVehicle(currentveh);
            return 1;
        }
        else SendClientMessage(playerid, COLOR_RED,"You're not admin!");
        {
            format(string, sizeof(string), "*%d Admin %s: Deleted the vehicle", PlayerInfo[playerid][pAdmin], sendername);
            SendAdminMessage(COLOR_YELLOW,string);
            return 1;
        }
        printf("Admin %s: Deleted the vehicle", sendername);
        SendClientMessage(playerid, COLOR_GRAD1,"Vehicle deleted!");
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
You are wrong. My post is the one that helps. If i make thhe code for you, you just copy/paste instead of work to fix your own errors. That's how i've learn. Try it.. If doesnn't work, just tell.

But ok.. Here you go, not tested, made almost sleeping, hope it works.

pawn Код:
if(strcmp(cmdtext, "/delveh", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /delveh");
            return 1;
        }
        if (PlayerInfo[playerid][pAdmin] >=2)
        {
            new currentveh = GetPlayerVehicleID(playerid);
            DestroyVehicle(currentveh);
            return 1;
        }
        else SendClientMessage(playerid, COLOR_RED,"You're not admin!");
        {
            format(string, sizeof(string), "*%d Admin %s: Deleted the vehicle", PlayerInfo[playerid][pAdmin], sendername);
            SendAdminMessage(COLOR_YELLOW,string);
            return 1;
        }
        printf("Admin %s: Deleted the vehicle", sendername);
        SendClientMessage(playerid, COLOR_GRAD1,"Vehicle deleted!");
    }
    return 1;
}
That is why I stated what was wrong, not made up a little trivia to guess where the problem is. Plus our commands are exactly the same, the only difference is the else statement.
Reply
#7

Test it... Added some returns... Just test and tell me if it works. I am better with ZCMD + SSCANF but..
Returns are more important than what you think.

EDIT: My bad, you are not the poster. Haha. Sorry. Didn't even see you posted before me. Your one is right i think.. But if you see, you added some returns to the original command.. That's what i said in the comment, lacking returns.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)