SA-MP Forums Archive
DCMD command not working at all. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: DCMD command not working at all. (/showthread.php?tid=271136)



DCMD command not working at all. - Jack_Leslie - 23.07.2011

Well I'm currently trying to do a bank robbery system, half way through it but the command just does nothing.

pawn Код:
dcmd_robbank(playerid, params[])
{
if(PlayerInfo[playerid][pLevel] < 2) return SendClientMessage(playerid, -1, "You need to be at least Level 3!");
if(!IsPlayerInRangeOfPoint(playerid, 2, 345.585968, 112.513107, 1008.184448) return SendClientMessage(playerid, -1, "You're not at the Robbing Point!");
if(IsACop(playerid)) return SendClientMessage(playerid, -1, "Cops cannot rob the bank!");
new Cops = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsACop(i))
    {
        Cops += 1;
    }
    }
        if(!(Cops >= 2))
        {
        SendClientMessage(playerid,COLOR_GREY,"There must be at least 2 Law Enforcement Officials online.");
        return 1;
}
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
SendClientMessageToAll(COLOR_LIGHTBLUE, "The Los Santos City bank is being robbed!");
return 1;
}



Re: ZCMD command not working at all. - Kitten - 23.07.2011

Um topic says ZCMD but its DCMD?

EDIT: nvm you changed topic name.

also try debugging it

with printf see if the command is working at all like all of it.


Re: ZCMD command not working at all. - JaTochNietDan - 23.07.2011

At what point does it "do nothing"? Try adding prints to determine that if you do not already know, that's the easiest way to find the line with the problem on it.


Re: ZCMD command not working at all. - Jack_Leslie - 23.07.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
At what point does it "do nothing"? Try adding prints to determine that if you do not already know, that's the easiest way to find the line with the problem on it.
It does nothing right at the start, if I'm lower then Level 2 it doesn't send me the return message for that.


Re: ZCMD command not working at all. - JaTochNietDan - 23.07.2011

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
It does nothing right at the start, if I'm lower then Level 2 it doesn't send me the return message for that.
Well for one thing that color doesn't look very valid, -1? What color are you intending it to be? It should be in hex format, but all I see is a negative integer, which seems a little odd, I don't know what kind of results that would turn up, but I would suggest using the function as it's intended to be used!

Anyway, I'm pretty sure it'll do something if it's called, so lets add some prints to debug it like I stated earlier, I'll help you add them:

pawn Код:
dcmd_robbank(playerid, params[])
{
    print("Success 1");
    if(PlayerInfo[playerid][pLevel] < 2) return SendClientMessage(playerid, -1, "You need to be at least Level 3!");
    print("Success 2");    
    if(!IsPlayerInRangeOfPoint(playerid, 2, 345.585968, 112.513107, 1008.184448) return SendClientMessage(playerid, -1, "You're not at the Robbing Point!");
    print("Success 3");
    if(IsACop(playerid)) return SendClientMessage(playerid, -1, "Cops cannot rob the bank!");
    new Cops = 0;
    print("Success 4");
    for(new i = 0; i < MAX_PLAYERS; i++)
        if(IsACop(i)) Cops += 1;
    print("Success 5");
    if(!(Cops >= 2))
    {
        print("Success 6");
        SendClientMessage(playerid,COLOR_GREY,"There must be at least 2 Law Enforcement Officials online.");
        return 1;
    }
    print("Success 7");
    //new sendername[MAX_PLAYER_NAME]; - Pointless? Never used in this snippet!
    //GetPlayerName(playerid, sendername, sizeof(sendername)); - Pointless? Never used in this snippet!
    SendClientMessageToAll(COLOR_LIGHTBLUE, "The Los Santos City bank is being robbed!");
    return 1;
}
Give that a run and tell me exactly what it prints out (I've also cleaned up your code a little as it was kind of hard to read!)


Re: ZCMD command not working at all. - Jack_Leslie - 23.07.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Well for one thing that color doesn't look very valid, -1? What color are you intending it to be? It should be in hex format, but all I see is a negative integer, which seems a little odd, I don't know what kind of results that would turn up, but I would suggest using the function as it's intended to be used!

Anyway, I'm pretty sure it'll do something if it's called, so lets add some prints to debug it like I stated earlier, I'll help you add them:

pawn Код:
dcmd_robbank(playerid, params[])
{
    print("Success 1");
    if(PlayerInfo[playerid][pLevel] < 2) return SendClientMessage(playerid, -1, "You need to be at least Level 3!");
    print("Success 2");    
    if(!IsPlayerInRangeOfPoint(playerid, 2, 345.585968, 112.513107, 1008.184448) return SendClientMessage(playerid, -1, "You're not at the Robbing Point!");
    print("Success 3");
    if(IsACop(playerid)) return SendClientMessage(playerid, -1, "Cops cannot rob the bank!");
    new Cops = 0;
    print("Success 4");
    for(new i = 0; i < MAX_PLAYERS; i++)
        if(IsACop(i)) Cops += 1;
    print("Success 5");
    if(!(Cops >= 2))
    {
        print("Success 6");
        SendClientMessage(playerid,COLOR_GREY,"There must be at least 2 Law Enforcement Officials online.");
        return 1;
    }
    print("Success 7");
    //new sendername[MAX_PLAYER_NAME]; - Pointless? Never used in this snippet!
    //GetPlayerName(playerid, sendername, sizeof(sendername)); - Pointless? Never used in this snippet!
    SendClientMessageToAll(COLOR_LIGHTBLUE, "The Los Santos City bank is being robbed!");
    return 1;
}
Give that a run and tell me exactly what it prints out (I've also cleaned up your code a little as it was kind of hard to read!)
I have "-1" on other commands and it works, it makes the color white for some unknown reason and it's quicker then putting COLOR_WHITE or anything. So, I tried your code, and again, it does nothing (prints nothing). A code above it (that works fine) might be making it not work, so here's the code above it including the robbank code:

pawn Код:
dcmd_report(playerid, params[])
{
    new target, msg[128], tString[128];
    if(sscanf(params, "us[128]", target, msg)) return SendClientMessage(playerid, -1, "How to report: /report [admin name] [message]");
    if(JustReported[playerid] == 1) return SendClientMessage(playerid, -1, "You must wait 10 seconds to report again!");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, -1, "That Admin is not online!");
    if(PlayerInfo[target][pAdmin] <=1) return SendClientMessage(playerid, -1, "That person is not an Admin!");
    //If all above checks out, the code below will execute
    JustReported[playerid] = 1;
    SetTimerEx("ReportReset", 10000, false, "i", playerid);
    new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(tString, sizeof(tString), "{CC1100}Report from {FFFFFF}[%d]%s: %s", playerid, sendername, msg);
    SendClientMessage(target,-1,tString);
    SendClientMessage(playerid, COLOR_YELLOW, "Report sent. Administrator will reply shortly.");
    return 1;
}



dcmd_robbank(playerid, params[])
{
    print("Success 1");
    if(PlayerInfo[playerid][pLevel] < 2) return SendClientMessage(playerid, COLOR_WHITE, "You need to be at least Level 3!");
    print("Success 2");
    if(!IsPlayerInRangeOfPoint(playerid, 2, 345.585968, 112.513107, 1008.184448) return SendClientMessage(playerid, COLOR_WHITE, "You're not at the Robbing Point!");
    print("Success 3");
    if(IsACop(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "Cops cannot rob the bank!");
    new Cops = 0;
    print("Success 4");
    for(new i = 0; i < MAX_PLAYERS; i++)
        if(IsACop(i)) Cops += 1;
    print("Success 5");
    if(!(Cops >= 2))
    {
        SendClientMessage(playerid,COLOR_GREY,"There must be at least 2 Law Enforcement Officials online.");
        return 1;
    }
    print("Success 6");
    new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SendClientMessageToAll(COLOR_LIGHTBLUE, "The Los Santos City bank is being robbed!");
    return 1;
}



Re: DCMD command not working at all. - JaTochNietDan - 23.07.2011

Interesting, can I see where you've put the other part of the dcmd command in OnPlayerCommandText?


Re: DCMD command not working at all. - Jack_Leslie - 23.07.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Interesting, can I see where you've put the other part of the dcmd command in OnPlayerCommandText?
pawn Код:
dcmd(oprison, 7, cmdtext);
    //dcmd(ouninvite, 9, cmdtext);
    dcmd(unban, 5, cmdtext);
    dcmd(banaccount, 10, cmdtext);
    dcmd(setaccent, 9, cmdtext);
    dcmd(deleteaccount, 13, cmdtext);
    dcmd(duel, 4, cmdtext);
    dcmd(report, 6, cmdtext);
I just realized I don't have the dcmd(robbank-- bit.. is that why ? :P


Re: DCMD command not working at all. - JaTochNietDan - 23.07.2011

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
pawn Код:
dcmd(oprison, 7, cmdtext);
    //dcmd(ouninvite, 9, cmdtext);
    dcmd(unban, 5, cmdtext);
    dcmd(banaccount, 10, cmdtext);
    dcmd(setaccent, 9, cmdtext);
    dcmd(deleteaccount, 13, cmdtext);
    dcmd(duel, 4, cmdtext);
    dcmd(report, 6, cmdtext);
I just realized I don't have the dcmd(robbank-- bit.. is that why ? :P
Of course that's why silly ! That means that the dcmd function you've created is never being called because there's nothing defined in OnPlayerCommandText to process the function!


Re: DCMD command not working at all. - Jack_Leslie - 23.07.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Of course that's why silly ! That means that the dcmd function you've created is never being called because there's nothing defined in OnPlayerCommandText to process the function!
My bad haha, forgot all about doing that. Thankyou!