SA-MP Forums Archive
CMD PROBLEM - 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)
+--- Thread: CMD PROBLEM (/showthread.php?tid=583363)



CMD PROBLEM - STONEGOLD - 27.07.2015

PHP код:
CMD:robbiz(playeridparams[])
{
    new 
chance random(3), bizowner GetID(BizInfo[BizRobCP[playerid]][bOwner]), fstr[256],fstr2[256];
    if(
BizRobCP[playerid] == -1) return SendClientMessage(playeridRED"You must be in a business checkpoint to use this command.");
    if(
gTeam[playerid] != CIVILIANS) return SendClientMessage(playeridRED"Only civilians can use this command.");
    if(
bizowner == playerid) return SendClientMessage(playeridRED"You cant rob your own business.");
    if(!
IsPlayerConnected(bizowner))
    {
        if((
gettime() - 120) < bizrobbed[BizRobCP[playerid]]) return SendClientMessage(playeridRED"This business has been robbed recently, try again later.");
        
SendClientMessage(playeridRED"You failed to rob the business [WANTED LEVEL INCREASED]");
        
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
        
format(fstrsizeof(fstr), "[DISPATCH]: Suspect %s [%d] has attempted to rob %s at %s"GetName(playerid), playeridBizInfo[BizRobCP[playerid]][bName], ReturnPlayerZone(playerid));
        
SendRadioMessageToCops(fstr);
         
format(fstr2sizeof(fstr2), "%s [%d] has attempted to rob your business at %s."GetName(playerid), playeridReturnPlayerZone(playerid));
        
SendClientMessage(bizownerREDfstr2);
        
bizrobbed[BizRobCP[playerid]] = gettime();
        return 
true;
    }
    if(
BizInfo[BizRobCP[playerid]][bEarnings] < 10000)
    {
        if((
gettime() - 120) < bizrobbed[BizRobCP[playerid]]) return SendClientMessage(playeridRED"This business has been robbed recently, try again later.");
        
SendClientMessage(playeridRED"You failed to rob the business [WANTED LEVEL INCREASED]");
        
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
        
format(fstrsizeof(fstr), "[DISPATCH]: Suspect %s [%d] has attempted to rob %s at %s"GetName(playerid), playeridBizInfo[BizRobCP[playerid]][bName], ReturnPlayerZone(playerid));
        
SendRadioMessageToCops(fstr);
         
format(fstr2sizeof(fstr2), "%s [%d] has attempted to rob your business at %s."GetName(playerid), playeridReturnPlayerZone(playerid));
        
SendClientMessage(bizownerREDfstr2);
        
bizrobbed[BizRobCP[playerid]] = gettime();
        return 
true;
    }
    if(
chance == 0)
    {
        if((
gettime() - 120) < bizrobbed[BizRobCP[playerid]]) return SendClientMessage(playeridRED"This business has been robbed recently, try again later.");
        
SendClientMessage(playeridWHITE"You are robbing the business, DON'T LEAVE THE CHECKPOINT!");
        
GameTextForPlayer(playerid"~w~Your ~g~Robbing ~w~The Business...~n~~r~Dont Leave ~w~The ~r~Checkpoint."250005);
        
format(fstrsizeof(fstr), "[ROBBERY]: %s [%d] is robbing %s at %s"GetName(playerid), playeridBizInfo[BizRobCP[playerid]][bName], ReturnPlayerZone(playerid));
        
SendRadioMessageToCops(fstr);
         
format(fstr2sizeof(fstr2), "%s [%d] is robbing your business at %s."GetName(playerid), playeridReturnPlayerZone(playerid));
        
SendClientMessage(bizownerREDfstr2);
        
biztimer{playerid} = SetTimerEx("BizRob"25000false"d"playerid);
           
ApplyAnimation(playerid,"ped","ARRESTgun",4.1,0,1,1,1,1);
        
IsPlayerRobbingBiz{playerid} = true;
        
bizrobbed[BizRobCP[playerid]] = gettime();
        return 
true;
    }
    else if(
chance == || chance == 2)
    {
        if((
gettime() - 120) < bizrobbed[BizRobCP[playerid]]) return SendClientMessage(playeridRED"This business has been robbed recently, try again later.");
        
SendClientMessage(playeridRED"You failed to rob the business [WANTED LEVEL INCREASED]");
        
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
        
format(fstrsizeof(fstr), "[DISPATCH]: Suspect %s [%d] has attempted to rob %s at %s"GetName(playerid), playeridBizInfo[BizRobCP[playerid]][bName], ReturnPlayerZone(playerid));
        
SendRadioMessageToCops(fstr);
         
format(fstr2sizeof(fstr2), "%s [%d] has attempted to rob your business at %s."GetName(playerid), playeridReturnPlayerZone(playerid));
        
SendClientMessage(bizownerREDfstr2);
        
bizrobbed[BizRobCP[playerid]] = gettime();
    }
    return 
true;

What's wrong with it? Whenever i type it it says SERVER ERROS: unknown command?


Re: CMD PROBLEM - Crayder - 27.07.2015

Try this:
pawn Код:
CMD:robbiz(playerid, params[])
{
    SendClientMessage(playerid, -1, "The command's being called!");
    new chance = random(3), bizowner = GetID(BizInfo[BizRobCP[playerid]][bOwner]), fstr[256],fstr2[256];
    if(BizRobCP[playerid] == -1) return SendClientMessage(playerid, RED, "You must be in a business checkpoint to use this command.");
    if(gTeam[playerid] != CIVILIANS) return SendClientMessage(playerid, RED, "Only civilians can use this command.");
    if(bizowner == playerid) return SendClientMessage(playerid, RED, "You cant rob your own business.");
    if(!IsPlayerConnected(bizowner))
    {
        if((gettime() - 120) < bizrobbed[BizRobCP[playerid]]) return SendClientMessage(playerid, RED, "This business has been robbed recently, try again later.");
        SendClientMessage(playerid, RED, "You failed to rob the business [WANTED LEVEL INCREASED]");
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 4);
        format(fstr, sizeof(fstr), "[DISPATCH]: Suspect %s [%d] has attempted to rob %s at %s", GetName(playerid), playerid, BizInfo[BizRobCP[playerid]][bName], ReturnPlayerZone(playerid));
        SendRadioMessageToCops(fstr);
         format(fstr2, sizeof(fstr2), "%s [%d] has attempted to rob your business at %s.", GetName(playerid), playerid, ReturnPlayerZone(playerid));
        SendClientMessage(bizowner, RED, fstr2);
        bizrobbed[BizRobCP[playerid]] = gettime();
        return true;
    }
    if(BizInfo[BizRobCP[playerid]][bEarnings] < 10000)
    {
        if((gettime() - 120) < bizrobbed[BizRobCP[playerid]]) return SendClientMessage(playerid, RED, "This business has been robbed recently, try again later.");
        SendClientMessage(playerid, RED, "You failed to rob the business [WANTED LEVEL INCREASED]");
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 4);
        format(fstr, sizeof(fstr), "[DISPATCH]: Suspect %s [%d] has attempted to rob %s at %s", GetName(playerid), playerid, BizInfo[BizRobCP[playerid]][bName], ReturnPlayerZone(playerid));
        SendRadioMessageToCops(fstr);
         format(fstr2, sizeof(fstr2), "%s [%d] has attempted to rob your business at %s.", GetName(playerid), playerid, ReturnPlayerZone(playerid));
        SendClientMessage(bizowner, RED, fstr2);
        bizrobbed[BizRobCP[playerid]] = gettime();
        return true;
    }
    if(chance == 0)
    {
        if((gettime() - 120) < bizrobbed[BizRobCP[playerid]]) return SendClientMessage(playerid, RED, "This business has been robbed recently, try again later.");
        SendClientMessage(playerid, WHITE, "You are robbing the business, DON'T LEAVE THE CHECKPOINT!");
        GameTextForPlayer(playerid, "~w~Your ~g~Robbing ~w~The Business...~n~~r~Dont Leave ~w~The ~r~Checkpoint.", 25000, 5);
        format(fstr, sizeof(fstr), "[ROBBERY]: %s [%d] is robbing %s at %s", GetName(playerid), playerid, BizInfo[BizRobCP[playerid]][bName], ReturnPlayerZone(playerid));
        SendRadioMessageToCops(fstr);
         format(fstr2, sizeof(fstr2), "%s [%d] is robbing your business at %s.", GetName(playerid), playerid, ReturnPlayerZone(playerid));
        SendClientMessage(bizowner, RED, fstr2);
        biztimer{playerid} = SetTimerEx("BizRob", 25000, false, "d", playerid);
           ApplyAnimation(playerid,"ped","ARRESTgun",4.1,0,1,1,1,1);
        IsPlayerRobbingBiz{playerid} = true;
        bizrobbed[BizRobCP[playerid]] = gettime();
        return true;
    }
    else if(chance == 1 || chance == 2)
    {
        if((gettime() - 120) < bizrobbed[BizRobCP[playerid]]) return SendClientMessage(playerid, RED, "This business has been robbed recently, try again later.");
        SendClientMessage(playerid, RED, "You failed to rob the business [WANTED LEVEL INCREASED]");
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 4);
        format(fstr, sizeof(fstr), "[DISPATCH]: Suspect %s [%d] has attempted to rob %s at %s", GetName(playerid), playerid, BizInfo[BizRobCP[playerid]][bName], ReturnPlayerZone(playerid));
        SendRadioMessageToCops(fstr);
         format(fstr2, sizeof(fstr2), "%s [%d] has attempted to rob your business at %s.", GetName(playerid), playerid, ReturnPlayerZone(playerid));
        SendClientMessage(bizowner, RED, fstr2);
        bizrobbed[BizRobCP[playerid]] = gettime();
    }
    return true;
}
If you retrieve the, "The command's being called," message, then you should get crashdetect to find the problem. If that's the case, recompile your script with the '-d3' flag and run the server with the crashdetect plugin installed.

If you do not retrieve the message, then there is something in your script preventing the command from being processed.