SA-MP Forums Archive
Problem with command - 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: Problem with command (/showthread.php?tid=312214)



Problem with command - Ld Est Ld - 20.01.2012

pawn Код:
CMD:hcspawnpos(playerid, params[]) {

    if(getPlayerBusinessID(playerid) >= 1) {

        new
            businessID = getPlayerBusinessID(playerid);

        if(businessVariables[businessID][bType] == 16) {
            if(IsPlayerInRangeOfPoint(playerid, 30.0, businessVariables[businessID][bExteriorPos][0], businessVariables[businessID][bExteriorPos][1], businessVariables[businessID][bExteriorPos][2])) {
                GetPlayerPos(playerid, businessVariables[businessID][bMiscPos][0], businessVariables[businessID][bMiscPos][1], businessVariables[businessID][bMiscPos][2]);
                SendClientMessage(playerid, COLOR_WHITE, "You have successfully altered the spawn position of your vehicle dealership business.");
            }
            else SendClientMessage(playerid, COLOR_GREY, "You must be within thirty metres of the exterior of your business.");
        }
        else SendClientMessage(playerid, COLOR_GREY, "You don't own a helicopter dealership.");
    }
    return 1;
}
Okey, I have a little problem with this command. ^^^^^
If I try to make Helicopter spawn position then it gives me this message all the time. "You must be within thirty metres of the exterior of your business."

Even if im from business like 100km away.


pawn Код:
CMD:bspawnpos(playerid, params[]) {

    if(getPlayerBusinessID(playerid) >= 1) {

        new
            businessID = getPlayerBusinessID(playerid);

        if(businessVariables[businessID][bType] == 5) {
            if(IsPlayerInRangeOfPoint(playerid, 30.0, businessVariables[businessID][bExteriorPos][0], businessVariables[businessID][bExteriorPos][1], businessVariables[businessID][bExteriorPos][2])) {
                GetPlayerPos(playerid, businessVariables[businessID][bMiscPos][0], businessVariables[businessID][bMiscPos][1], businessVariables[businessID][bMiscPos][2]);
                SendClientMessage(playerid, COLOR_WHITE, "You have successfully altered the spawn position of your vehicle dealership business.");
            }
            else SendClientMessage(playerid, COLOR_GREY, "You must be within thirty metres of the exterior of your business.");
        }
        else SendClientMessage(playerid, COLOR_GREY, "You don't own a vehicle dealership.");
    }
    return 1;
}
This is the original command.^^^^


Re: Problem with command - Bogdan1992 - 20.01.2012

You should get the position first then put that Range

EDIT:

PHP код:
CMD:hcspawnpos(playeridparams[]) {
    if(
getPlayerBusinessID(playerid) >= 1) {
        new
            
businessID getPlayerBusinessID(playerid);
            
GetPlayerPos(playeridbusinessVariables[businessID][bMiscPos][0], businessVariables[businessID][bMiscPos][1], businessVariables[businessID][bMiscPos][2]);
        if(
businessVariables[businessID][bType] == 16) {
            if(
IsPlayerInRangeOfPoint(playerid30.0businessVariables[businessID][bExteriorPos][0], businessVariables[businessID][bExteriorPos][1], businessVariables[businessID][bExteriorPos][2])) {
                
SendClientMessage(playeridCOLOR_WHITE"You have successfully altered the spawn position of your vehicle dealership business.");
            }
            else 
SendClientMessage(playeridCOLOR_GREY"You must be within thirty metres of the exterior of your business.");
        }
        else 
SendClientMessage(playeridCOLOR_GREY"You don't own a helicopter dealership.");
    }
    return 
1;




Re: Problem with command - Konstantinos - 20.01.2012

Quote:
Originally Posted by Bogdan1992
Посмотреть сообщение
You should get the position first then put that Range

EDIT:

PHP код:
CMD:hcspawnpos(playeridparams[]) {
    if(
getPlayerBusinessID(playerid) >= 1) {
        new
            
businessID getPlayerBusinessID(playerid);
            
GetPlayerPos(playeridbusinessVariables[businessID][bMiscPos][0], businessVariables[businessID][bMiscPos][1], businessVariables[businessID][bMiscPos][2]);
        if(
businessVariables[businessID][bType] == 16) {
            if(
IsPlayerInRangeOfPoint(playerid30.0businessVariables[businessID][bExteriorPos][0], businessVariables[businessID][bExteriorPos][1], businessVariables[businessID][bExteriorPos][2])) {
                
SendClientMessage(playeridCOLOR_WHITE"You have successfully altered the spawn position of your vehicle dealership business.");
            }
            else 
SendClientMessage(playeridCOLOR_GREY"You must be within thirty metres of the exterior of your business.");
        }
        else 
SendClientMessage(playeridCOLOR_GREY"You don't own a helicopter dealership.");
    }
    return 
1;

He already has it!
Код:
CMD:bspawnpos(playerid, params[]) {

    if(getPlayerBusinessID(playerid) >= 1) {

        new
            businessID = getPlayerBusinessID(playerid);

        if(businessVariables[businessID][bType] == 5) {
            if(IsPlayerInRangeOfPoint(playerid, 30.0, businessVariables[businessID][bExteriorPos][0], businessVariables[businessID][bExteriorPos][1], businessVariables[businessID][bExteriorPos][2])) {
                GetPlayerPos(playerid, businessVariables[businessID][bMiscPos][0], businessVariables[businessID][bMiscPos][1], businessVariables[businessID][bMiscPos][2]);
                SendClientMessage(playerid, COLOR_WHITE, "You have successfully altered the spawn position of your vehicle dealership business.");
            }
            else SendClientMessage(playerid, COLOR_GREY, "You must be within thirty metres of the exterior of your business.");
        }
        else SendClientMessage(playerid, COLOR_GREY, "You don't own a vehicle dealership.");
    }
    return 1;
}
Make sure the coordinates from the range are correct. If you type the command 30 meters away it will show you the error message.


Re: Problem with command - Bogdan1992 - 20.01.2012

You realize that the position of the function must be in the right place. First thing you must get the position, then you check if is in range, right?


Re: Problem with command - Ld Est Ld - 20.01.2012

CMD:bspawnpos is alright, i just copied from this, changed the "if(businessVariables[businessID][bType] == 5)" to "if(businessVariables[businessID][bType] == 16) { " and changed name, now I'm kinda stuck ...


Re: Problem with command - Konstantinos - 20.01.2012

GetPlayerPos is useless because it checks if a player is in range of a point.


Re: Problem with command - Ld Est Ld - 20.01.2012

I'll try to figure out something, thanks for you're help guys.