PDA

View Full Version : [Help] I need help with this


BigGreen
26/06/2015, 01:18 PM
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;

Prokill911
26/06/2015, 01:24 PM
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


getStandingExit(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;
}



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

BigGreen
26/06/2015, 01:28 PM
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


getStandingExit(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;
}


Will it work with the business???

rappy93
26/06/2015, 01:31 PM
Houses and businesses usually work the same way so most likely it will work if you apply the above code for businesses, like this :


getStandingExit(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;
}

BigGreen
26/06/2015, 01:33 PM
Houses and businesses usually work the same way so most likely it will work if you apply the above code for businesses, like this :


getStandingExit(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 how do i add these codes to the one i posted above i dont want to screw it up

Prokill911
26/06/2015, 01:36 PM
getStandingExit(playerid, Float:radius = 15.0) {
for(new i=0;i<sizeof(Houses);i++) {
if(IsPlayerInRangeOfPoint(playerid, radius, Houses[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(playerid, Float:radi = 2.0) {
for(new i=0;i<sizeof(Houses);i++) {
if(IsPlayerInRangeOfPoint(playerid, radius, Houses[Player[playerid][i]][hExteriorX], Houses[Player[playerid][i]][hExteriorY], Houses[Player[playerid][i]][hExteriorZ])) {
return i;
}
}
return -1;
}



command(lockhouse, playerid, params[]) {
#pragma unused params
new string[128];
new houseid = getStandingHouse(playerid);
if(houseid == -1) {
new insidehouse = getStandingExit(playerid);
if(insidehouse == -1) {
SendClientMessage(playerid, WHITE, "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(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;
}



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

rappy93
26/06/2015, 01:36 PM
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:

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

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.

Prokill911
26/06/2015, 01:38 PM
getStandingExit(playerid, Float:radius = 15.0) {
for(new i=0;i<sizeof(Houses);i++) {
if(IsPlayerInRangeOfPoint(playerid, radius, Houses[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(playerid, Float:radi = 2.0) {
for(new i=0;i<sizeof(Houses);i++) {
if(IsPlayerInRangeOfPoint(playerid, radius, Houses[Player[playerid][i]][hExteriorX], Houses[Player[playerid][i]][hExteriorY], Houses[Player[playerid][i]][hExteriorZ])) {
return i;
}
}
return -1;
}



command(lockhouse, playerid, params[]) {
#pragma unused params
new string[128];
new houseid = getStandingHouse(playerid);
new insidehouse = getStandingExit(playerid);
if(houseid == -1) {
if(insidehouse == -1) {
SendClientMessage(playerid, WHITE, "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(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;
}



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