[Help] I need help with this
#1

Hello there so i tried to make this command work while inside like if i do /lockhouse outside it locks the house but when i go inside it says your not near your house and also i want it to work the same with the business to /lockbusiness and i want it to /lockbusiness while inside

Код:
command(lockhouse, playerid, params[])
{
	#pragma unused params
	new string[128];
	if(!IsPlayerInRangeOfPoint(playerid, 5, Houses[Player[playerid][House]][hExteriorX], Houses[Player[playerid][House]][hExteriorY], Houses[Player[playerid][House]][hExteriorZ]))
	{
		 return SendClientMessage(playerid, WHITE, "You are not near a house that you own!");
	}
	if(Player[playerid][House] > 0)
	{
	    if(Houses[Player[playerid][House]][LockStatus] == 1)
	    {
	        Houses[Player[playerid][House]][LockStatus] = 0;
	        format(string, sizeof(string), "** %s has unlocked their house door.", GetName(playerid));
            NearByMessage(playerid, SCRIPTPURPLE, string);
	    }
	    else
	    {
	        Houses[Player[playerid][House]][LockStatus] = 1;
	        format(string, sizeof(string), "** %s has locked their house door.", GetName(playerid));
            NearByMessage(playerid, SCRIPTPURPLE, string);
	    }
	}
	return 1;
}
Код:
command(lockbusiness, playerid, params[])
{
	#pragma unused params
	new string[128];
	if(!IsPlayerInRangeOfPoint(playerid, 5, Businesses[Player[playerid][Business]][bExteriorX], Businesses[Player[playerid][Business]][bExteriorY], Businesses[Player[playerid][Business]][bExteriorZ]))
	{
		 return SendClientMessage(playerid, WHITE, "You are not near a business that you own!");
	}
	if(Player[playerid][Business] > 0)
	{
	    if(Businesses[Player[playerid][Business]][bLockStatus] == 1)
	    {
	        Businesses[Player[playerid][Business]][bLockStatus] = 0;
	        format(string, sizeof(string), "** %s has unlocked their business doors.", GetName(playerid));
            NearByMessage(playerid, SCRIPTPURPLE, string);
	    }
	    else
	    {
	        Businesses[Player[playerid][Business]][bLockStatus] = 1;
	        format(string, sizeof(string), "** %s has locked their business doors.", GetName(playerid));
            NearByMessage(playerid, SCRIPTPURPLE, string);
	    }
	}
	return 1;
Reply
#2

Simply put...
Make a stock function

which loops through ALL your houses getting each EXIT X Y Z
( The position they stand on to EXIT the house )

Then
In your "lockhouse"

Put an if statement
example

PHP код:
getStandingExit(playeridFloat:radius 15.0) {
    for(new 
i=0;i<sizeof(Houses);i++) {
        if(
IsPlayerInRangeOfPoint(playeridradiusHouses[Player[i][House]][hExteriorX], Houses[Player[i][House]][hExteriorY], Houses[Player[i][House]][hExteriorZ])) {
            return 
i;
        }
    }
    return -
1;

OBVIOUSLY, You need to modify the code...
Because I just copied your EXTERIOR...
You need to get the INTERIOR coords
Reply
#3

Quote:
Originally Posted by Prokill911
Посмотреть сообщение
Simply put...
Make a stock function

which loops through ALL your houses getting each EXIT X Y Z
( The position they stand on to EXIT the house )

Then
In your "lockhouse"

Put an if statement
example

PHP код:
getStandingExit(playeridFloat:radius 15.0) {
    for(new 
i=0;i<sizeof(Houses);i++) {
        if(
IsPlayerInRangeOfPoint(playeridradiusHouses[Player[i][House]][hExteriorX], Houses[Player[i][House]][hExteriorY], Houses[Player[i][House]][hExteriorZ])) {
            return 
i;
        }
    }
    return -
1;

Will it work with the business
Reply
#4

Houses and businesses usually work the same way so most likely it will work if you apply the above code for businesses, like this :

PHP код:
getStandingExit(playeridFloat:radius 15.0) { 
    for(new 
i=0;i<sizeof(Businesses);i++) { 
        if(
IsPlayerInRangeOfPoint(playeridradiusBusinesses[Player[i][Business]][bExteriorX], Businesses[Player[i][Business]][bExteriorY], Businesses[Player[i][Business]][bExteriorZ])) { 
            return 
i
        } 
    } 
    return -
1

Reply
#5

Quote:
Originally Posted by rappy93
Посмотреть сообщение
Houses and businesses usually work the same way so most likely it will work if you apply the above code for businesses, like this :

PHP код:
getStandingExit(playeridFloat:radius 15.0) { 
    for(new 
i=0;i<sizeof(Businesses);i++) { 
        if(
IsPlayerInRangeOfPoint(playeridradiusBusinesses[Player[i][Business]][bExteriorX], Businesses[Player[i][Business]][bExteriorY], Businesses[Player[i][Business]][bExteriorZ])) { 
            return 
i
        } 
    } 
    return -
1

And how do i add these codes to the one i posted above i dont want to screw it up
Reply
#6

PHP код:
getStandingExit(playeridFloat:radius 15.0) {
    for(new 
i=0;i<sizeof(Houses);i++) {
        if(
IsPlayerInRangeOfPoint(playeridradiusHouses[Player[playerid][i]][hExteriorX], Houses[Player[playerid][i]][hExteriorY], Houses[Player[playerid][i]][hExteriorZ])) { // <--- EDIT THIS TO BE YOUR HOUSE EXIT COORDS 
            
return i;
        }
    }
    return -
1;
}
getStandingHouse(playeridFloat:radi 2.0) {
    for(new 
i=0;i<sizeof(Houses);i++) {
        if(
IsPlayerInRangeOfPoint(playeridradiusHouses[Player[playerid][i]][hExteriorX], Houses[Player[playerid][i]][hExteriorY], Houses[Player[playerid][i]][hExteriorZ])) {
            return 
i;
        }
    }
    return -
1;
}
command(lockhouseplayeridparams[]) {
    
#pragma unused params
    
new string[128];
    new 
houseid getStandingHouse(playerid);
    if(
houseid == -1) {
        new 
insidehouse getStandingExit(playerid);
        if(
insidehouse == -1) {
            
SendClientMessage(playeridWHITE"You're not near your near your house door!");
            return 
1;
        }
    }
    if(
Player[playerid][House] == houseid) {
        if(
Houses[Player[playerid][House]][LockStatus] == 1) {
            
Houses[Player[playerid][House]][LockStatus] = 0;
            
format(stringsizeof(string), "** %s has unlocked their house door."GetName(playerid));
            
NearByMessage(playeridSCRIPTPURPLEstring);
        } else {
            
Houses[Player[playerid][House]][LockStatus] = 1;
            
format(stringsizeof(string), "** %s has locked their house door."GetName(playerid));
            
NearByMessage(playeridSCRIPTPURPLEstring);
        }
    }
    return 
1;

THAT SHOULD WORK....

For your house...
Your biz, You need to figure out yourself..
I'm not doing all the work for you lol

YOU WILL NEED TO EDIT THE
getStandingExit
if(IsPlayerInRange
The X Y Z -- SET them to your house exit names
Reply
#7

Quote:
Originally Posted by BigGreen
Посмотреть сообщение
And how do i add these codes to the one i posted above i dont want to screw it up

I don't know, I don't see your script. I guess you can go where you have your functions defined (public or stock) and add these:
pawn Код:
function getBStandingExit(playerid, Float:radius = 15.0) {  
    for(new i=0;i<sizeof(Businesses);i++) {  
        if(IsPlayerInRangeOfPoint(playerid, radius, Businesses[Player[i][Business]][bExteriorX], Businesses[Player[i][Business]][bExteriorY], Businesses[Player[i][Business]][bExteriorZ])) {  
            return i;  
        }  
    }  
    return -1;  
}
and
pawn Код:
function getHStandingExit(playerid, Float:radius = 15.0) {
    for(new i=0;i<sizeof(Houses);i++) {
        if(IsPlayerInRangeOfPoint(playerid, radius, Houses[Player[i][House]][hExteriorX], Houses[Player[i][House]][hExteriorY], Houses[Player[i][House]][hExteriorZ])) {
            return i;
        }
    }
    return -1;
}
Then use them in the commands like in the example above.
Reply
#8

PHP код:
getStandingExit(playeridFloat:radius 15.0) {
    for(new 
i=0;i<sizeof(Houses);i++) {
        if(
IsPlayerInRangeOfPoint(playeridradiusHouses[Player[playerid][i]][hExteriorX], Houses[Player[playerid][i]][hExteriorY], Houses[Player[playerid][i]][hExteriorZ])) { // <--- EDIT THIS TO BE YOUR HOUSE EXIT COORDS 
            
return i;
        }
    }
    return -
1;
}
getStandingHouse(playeridFloat:radi 2.0) {
    for(new 
i=0;i<sizeof(Houses);i++) {
        if(
IsPlayerInRangeOfPoint(playeridradiusHouses[Player[playerid][i]][hExteriorX], Houses[Player[playerid][i]][hExteriorY], Houses[Player[playerid][i]][hExteriorZ])) {
            return 
i;
        }
    }
    return -
1;
}
command(lockhouseplayeridparams[]) {
    
#pragma unused params
    
new string[128];
    new 
houseid getStandingHouse(playerid);
    new 
insidehouse getStandingExit(playerid);
    if(
houseid == -1) {
        if(
insidehouse == -1) {
            
SendClientMessage(playeridWHITE"You're not near your near your house door!");
            return 
1;
        } else {
            
houseid insidehouse;
        }
    }
    if(
Player[playerid][House] == houseid) {
        if(
Houses[Player[playerid][House]][LockStatus] == 1) {
            
Houses[Player[playerid][House]][LockStatus] = 0;
            
format(stringsizeof(string), "** %s has unlocked their house door."GetName(playerid));
            
NearByMessage(playeridSCRIPTPURPLEstring);
        } else {
            
Houses[Player[playerid][House]][LockStatus] = 1;
            
format(stringsizeof(string), "** %s has locked their house door."GetName(playerid));
            
NearByMessage(playeridSCRIPTPURPLEstring);
        }
    }
    return 
1;

THAT SHOULD WORK....

For your house...
Your biz, You need to figure out yourself..
I'm not doing all the work for you lol

YOU WILL NEED TO EDIT THE
getStandingExit
if(IsPlayerInRange
The X Y Z -- SET them to your house exit names
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)