small problem
#1

i have a problem with this code, i've made garage system with the house id, everything works except lock and unlock have a look on it.
Код:
CMD:lockgarage(playerid, params[])
{
	new string[128];
	for(new i = 0; i< sizeof(GarageInfo); i++)
	{
		if(IsPlayerInRangeOfPoint(playerid, 5, GarageInfo[i][gExteriorX], GarageInfo[i][gExteriorY], GarageInfo[i][gExteriorZ]) || IsPlayerInRangeOfPoint(playerid, 5, 1860.0675,-2347.2207,-37.4430))
		{
			if(strmatch(HouseInfo[GarageInfo[i][gHouseID]][hOwner],GetPlayerNameEx(playerid)))
			{
				if(!GarageInfo[i][gLock])
				{
					GarageInfo[i][gLock] = 1;
					format(string, sizeof(string), "* %s unlocks their garage.", RPN(playerid));
					ProxDetector(15.0, playerid, string, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME);
					GText(playerid, "~g~Garage Unlocked", 3500, 3);
				}
				else if(GarageInfo[i][gLock])
				{
					GarageInfo[i][gLock] = 0;
					format(string, sizeof(string), "* %s locks their garage", RPN(playerid));
					ProxDetector(15.0, playerid, string, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME);
					GText(playerid, "~r~Garage Locked", 3500, 3);
				}
				SaveGarages(i);
			}
		}
	}
	return 1;
}
and here's the stock of strmatch
Код:
stock strmatch(const String1[], const String2[])
{
	if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
	{
		return true;
	}
	else
	{
		return false;
	}
}
Reply
#2

Tried debugging it?

For example:
Код:
CMD:lockgarage(playerid, params[])
{
	new string[128];
	for(new i = 0; i< sizeof(GarageInfo); i++)
	{
                print("1");
		if(IsPlayerInRangeOfPoint(playerid, 5, GarageInfo[i][gExteriorX], GarageInfo[i][gExteriorY], GarageInfo[i][gExteriorZ]) || IsPlayerInRangeOfPoint(playerid, 5, 1860.0675,-2347.2207,-37.4430))
		{
                        print("2");
			if(strmatch(HouseInfo[GarageInfo[i][gHouseID]][hOwner],GetPlayerNameEx(playerid)))
			{
                                print("3");
				if(!GarageInfo[i][gLock])
				{
					GarageInfo[i][gLock] = 1;
					format(string, sizeof(string), "* %s unlocks their garage.", RPN(playerid));
					ProxDetector(15.0, playerid, string, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME);
					GText(playerid, "~g~Garage Unlocked", 3500, 3);
                                        print("4");
				}
				else if(GarageInfo[i][gLock])
				{
					GarageInfo[i][gLock] = 0;
					format(string, sizeof(string), "* %s locks their garage", RPN(playerid));
					ProxDetector(15.0, playerid, string, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME);
					GText(playerid, "~r~Garage Locked", 3500, 3);
                                        print("5");
				}
				SaveGarages(i);
                                print("6");
			}
                        // so on and forth.
		}
	}
	return 1;
}
Reply
#3

it's working in my old script but it doesn't work in my new one, and sorry i don't know what is debugging?
actually the cmd is doing nothing.
EDIT:im gonna test it right now
EDIT: have a look Oo
Код:
[23:58:37] 1
[23:58:37] 1
[23:58:37] 2
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:37] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 2
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
[23:58:39] 1
Reply
#4

Ok. You have a continuous loop. Use break to stop it once you have an avaliable house. I.e:

Код:
CMD:lockgarage(playerid, params[])
{
	new string[128];
	for(new i = 0; i< sizeof(GarageInfo); i++)
	{
                print("1");
		if(IsPlayerInRangeOfPoint(playerid, 5, GarageInfo[i][gExteriorX], GarageInfo[i][gExteriorY], GarageInfo[i][gExteriorZ]) || IsPlayerInRangeOfPoint(playerid, 5, 1860.0675,-2347.2207,-37.4430))
		{
                        print("2");
			if(!strcmp(HouseInfo[GarageInfo[i][gHouseID]][hOwner],GetPlayerNameEx(playerid)))
			{
                                print("3");
				if(!GarageInfo[i][gLock])
				{
					GarageInfo[i][gLock] = 1;
					format(string, sizeof(string), "* %s unlocks their garage.", RPN(playerid));
					ProxDetector(15.0, playerid, string, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME);
					GText(playerid, "~g~Garage Unlocked", 3500, 3);
                                        print("4");
				}
				else if(GarageInfo[i][gLock])
				{
					GarageInfo[i][gLock] = 0;
					format(string, sizeof(string), "* %s locks their garage", RPN(playerid));
					ProxDetector(15.0, playerid, string, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME);
					GText(playerid, "~r~Garage Locked", 3500, 3);
                                        print("5");
				}
				SaveGarages(i);
                                print("6");
			}
                        // so on and forth.
                        break;
		}
	}
	return 1;
}
and from the debugs you have provided, there is something wrong with strmatch. So lets replace it with strcmp for a quick test.
Reply
#5

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
Ok. You have a continuous loop. Use break to stop it once you have an avaliable house. I.e:

Код:
CMD:lockgarage(playerid, params[])
{
	new string[128];
	for(new i = 0; i< sizeof(GarageInfo); i++)
	{
                print("1");
		if(IsPlayerInRangeOfPoint(playerid, 5, GarageInfo[i][gExteriorX], GarageInfo[i][gExteriorY], GarageInfo[i][gExteriorZ]) || IsPlayerInRangeOfPoint(playerid, 5, 1860.0675,-2347.2207,-37.4430))
		{
                        print("2");
			if(!strcmp(HouseInfo[GarageInfo[i][gHouseID]][hOwner],GetPlayerNameEx(playerid)))
			{
                                print("3");
				if(!GarageInfo[i][gLock])
				{
					GarageInfo[i][gLock] = 1;
					format(string, sizeof(string), "* %s unlocks their garage.", RPN(playerid));
					ProxDetector(15.0, playerid, string, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME);
					GText(playerid, "~g~Garage Unlocked", 3500, 3);
                                        print("4");
				}
				else if(GarageInfo[i][gLock])
				{
					GarageInfo[i][gLock] = 0;
					format(string, sizeof(string), "* %s locks their garage", RPN(playerid));
					ProxDetector(15.0, playerid, string, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME, COLOR_ACCIONME);
					GText(playerid, "~r~Garage Locked", 3500, 3);
                                        print("5");
				}
				SaveGarages(i);
                                print("6");
			}
                        // so on and forth.
                        break;
		}
	}
	return 1;
}
and from the debugs you have provided, there is something wrong with strmatch. So lets replace it with strcmp for a quick test.
okay
it's working but i can open and close all garages xD
Reply
#6

Try this instead:
Код:
if(strcmp(HouseInfo[GarageInfo[i][gHouseID]][hOwner],GetPlayerNameEx(playerid)))
Reply
#7

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
Try this instead:
Код:
if(strcmp(HouseInfo[GarageInfo[i][gHouseID]][hOwner],GetPlayerNameEx(playerid)))
That's what i'm using actally i did this instead of !strcmp, anyway i've tried it it only stands in 1 and 2, and stops.
so this one is working perfect but with all garages.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)