/delivermats help - +rep!
#1

Okay, I had two commands:


Код:
CMD:getmats(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 1168.90, 1361.76, 10.50)) return SCM(playerid, COLOR_WHITE, "You aren't at the material's pickup point!");
    {
        SendClientMessage(playerid,COLOR_RED,"You have gotten a materials package, deliver it to the checkpoint to recieve the materials.");
        SetPlayerCheckpoint(playerid, 2179.7886,-2263.6206,14.7734, 3.0);
        PlayerInfo[playerid][pGotMaterials] = 1;
    }
    return 1;
}

CMD:delivermats(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 2179.7886,-2263.6206,14.7734)) return SCM(playerid, COLOR_RED, "You delivered the package and recieved 250 materials.");
    {
        if(PlayerInfo[playerid][pGotMaterials] == 0) return SendClientMessage(playerid, COLOR_GREY, "You do not have the packages.");
        PlayerInfo[playerid][pMaterials] += 250;
		PlayerInfo[playerid][pGotMaterials] = 0;
    }
    SendClientMessage(playerid, COLOR_WHITE, "You aren't in-range of the material's drop-off!");
    return 1;
}
When you get the the materials it gives you pGotMaterials = 1 - So it gives you 1 of the package basically, and on the /delivermats it makes sure you have the pGotMaterials otherwise you cant do /delivermats at the point since you can abuse it. But when you do /delivermats it doesn't take away the pGotMaterials and it doesn't give you the 250 materials. It says you have delivered them but it doesn't remove it and give you the materials so I can't mat run since I don't get the materials and I don't get the package, anyone who can fix this? Also, make it so you must have a job to, so like if(PlayerInfo[playerid][pJob] == 0) return SCM(playerid, COLOR_WHITE, "You don't have the arms dealer job!");
I don't know if thats ride so could someone implement having the job on both cmds /delivermats and /getmats - if you have pJob == 1 then you have the job if you have anything above or below you dont have it.

So could someone fix this please? +rep to anyone who can, thanks so much!
Reply
#2

Anyone, please
Reply
#3

This is basicly becuse you are using return before you have done the command,
"return" means = "Stop this and go back to normal, (or next function, but in this case normal)"
and you are using
if(IsPlayerInRangeOfPoint(playerid, 5.0, 2179.7886,-2263.6206,14.7734)) return SCM(playerid, COLOR_RED, "You delivered the package and recieved 250 materials.");
that does so when the command comes here you'll end the command and get back to normal.
if you take this away and just does it like:

Код:
CMD:delivermats(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 2179.7886,-2263.6206,14.7734)){
        if(PlayerInfo[playerid][pGotMaterials] == 0) return SendClientMessage(playerid, COLOR_GREY, "You do not have the packages.");
        PlayerInfo[playerid][pMaterials] += 250;
        PlayerInfo[playerid][pGotMaterials] = 0;
        SCM(playerid, COLOR_RED, "You delivered the package and recieved 250 materials.");
        return 1;//instead you can return here if you want the command to stop here becuse it have done everything it's desired to (notice this will only get called if the player have the materials)
    }//and here you use else(you don't have to but it looks nicer :) )
    else{
    SendClientMessage(playerid, COLOR_WHITE, "You aren't in-range of the material's drop-off!");
    }
    return 1;
}
Hope I helped a-lot
Reply
#4

Thank you, you fixed it! +rep

How can I make it so both commands have it so you must have the Arms Dealer Job
If you have pJob == 1 then you have the job, anything above like 2 means you dont have a job and 0 means you dont how can i do this

thanks
Reply
#5

Where you want this to be you add
if(PlayerInfo[playerid][pJob] != 1) return SendCleientMessage(playerid, COLOR_WHITE, "[CHANGE THIS ]You don't have the job and can't take the mats");// != means "Is not equal to" while == means is equal to, so i check if the job not is equal to 1 then you should retrun (stop the command and SendClientMesage to the player with the text you want. Change the text to whatever you want it to be

Add this everywhere where you want to check if the player got the job(if they don't got it this is going to stop the command and send a message to the palyer)

example:

Код:
CMD:delivermats(playerid, params[])
{
   if(PlayerInfo[playerid][pJob] != 1) return SendCleientMessage(playerid, COLOR_WHITE, "[CHANGE THIS :)]You don't have the job and can't take the mats");//you can add it later to but the earlier you check it the less other thing the script have to do before detecting this
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 2179.7886,-2263.6206,14.7734)){
        if(PlayerInfo[playerid][pGotMaterials] == 0) return SendClientMessage(playerid, COLOR_GREY, "You do not have the packages.");
        PlayerInfo[playerid][pMaterials] += 250;
        PlayerInfo[playerid][pGotMaterials] = 0;
        SCM(playerid, COLOR_RED, "You delivered the package and recieved 250 materials.");
        return 1;//instead you can return here if you want the command to stop here becuse it have done everything it's desired to (notice this will only get called if the player have the materials)
    }//and here you use else(you don't have to but it looks nicer :) )
    else{
    SendClientMessage(playerid, COLOR_WHITE, "You aren't in-range of the material's drop-off!");
    }
    return 1;
}
Reply
#6

Thank you so much!
Reply
#7

I got loose indiciations help
Reply
#8

On, what line did you receive " Loose Indications "

Код:
   else
   {
    SendClientMessage(playerid, COLOR_WHITE, "You aren't in-range of the material's drop-off!");
    }
    return 1;
}
^- that is the lower half of your issue.
Reply
#9

Код:
CMD:delivermats(playerid, params[])
{
    if(PlayerInfo[playerid][pJob] != 1) return SendCleientMessage(playerid, COLOR_WHITE, "[CHANGE THIS :)]You don't have the job and can't take the mats");//you can add it later to but the earlier you check it the less other thing the script have to do before detecting this
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 2179.7886,-2263.6206,14.7734)){
        if(PlayerInfo[playerid][pGotMaterials] == 0) return SendClientMessage(playerid, COLOR_GREY, "You do not have the packages.");
        PlayerInfo[playerid][pMaterials] += 250;
        PlayerInfo[playerid][pGotMaterials] = 0;
        SCM(playerid, COLOR_RED, "You delivered the package and recieved 250 materials.");
        return 1;//instead you can return here if you want the command to stop here becuse it have done everything it's desired to (notice this will only get called if the player have the materials)
    }//and here you use else(you don't have to but it looks nicer :) )
    else{
        SendClientMessage(playerid, COLOR_WHITE, "You aren't in-range of the material's drop-off!");
    }
    return 1;
}
the thing i added could be the one it, I've fixed it here
EDIT: now i've edited it done and it should be good.
Reply
#10

Quote:
Originally Posted by RLGaming
Посмотреть сообщение
I got loose indiciations help
For any loose indentation error add
pawn Код:
#pragma tabsize 0
at top of your script.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)