biz plant not working. -
TheLeech - 24.01.2019
When I type /biz plant or /biz edit near my business nothing happens.
Code:
COMMAND:biz(playerid, params[])
{
if (PlayerInfo[playerid][LoggedIn] == false) return true;
new string[128], param[64], amount, amount2;
if(sscanf(params, "s[64]I(-1)I(-1)", param, amount, amount2))
{
scm(playerid, COLOR_GREEN, "/biz [usage]");
scm(playerid, COLOR_GREY, " plant | edit | select |");
}
if(strcmp(param, "plant", true) == 0)
{
new allow = FurnRight(playerid, 1);
if(allow > 0) {
if(amount == (-1)) {
ShowModelSelectionMenuEx(playerid, FurnObjs, sizeof(FurnObjs), "Furniture List", 8, 16.0, 0.0, -55.0);
} else {
if(amount < 320 || amount > 35000) return scm(playerid, -1, "Invalid Object ID!");
if(GetPlayerInterior(playerid) == 0 && GetPlayerVirtualWorld(playerid) == 0 && IsInvalidObjectID(amount)) return scm(playerid, -1, "This is not a valid outdoor furniture object!");
new foundid = -1;
for(new i = 0; i < MAX_OBJECT_ARRAY; i++) {
if(ObjectList[i][oID] == amount) {
foundid=i;
break;
}
}
if(foundid == -1) return scm(playerid, -1, "Invalid Object ID!");
new Float:X, Float:Y, Float:Z, obj = 0;
GetPlayerPos(playerid, X, Y, Z);
obj = CreatePlayerObject(playerid, amount, X+1.0, Y+1.0, Z, 0.0, 0.0, 0.0, 100.0);
SetPVarInt(playerid, "FurnObject", obj);
SetPVarInt(playerid, "EditorMode", 3);
SetPVarInt(playerid, "Mute", 1);
PlayerInfo[playerid][pFurnID]=amount;
EditPlayerObject(playerid, obj);
format(string, sizeof(string),"%s selected, use the SPRINT key to navigate.", ObjectList[foundid][oName]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
}
else if(strcmp(param, "edit", true) == 0)
{
if(FurnRight(playerid, 1)){ GetCloseBizzObject(playerid, FurnRight(playerid, 1)); }
}
else if(strcmp(param, "removeall", true) == 0)
{
if(FurnRight(playerid, 1)) {
ShowPlayerDialog(playerid, DIALOG_BUSINESS_REMOVEALL, DIALOG_STYLE_MSGBOX, "Remove all furniture objects", "Are you sure you want to remove all of your current business furniture objects?", "Yes", "No");
} else SendClientMessage(playerid, COLOR_GREY, "You don't have permission to furnish this business.");
}
return 1;
}
stock FurnRight(playerid, type)
{
new key = -1;
if(type == 1)
{
for(new i = 0; i < sizeof(BusinessInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 150.0,BusinessInfo[i][EnterX],BusinessInfo[i][EnterY],BusinessInfo[i][EnterZ]))
{
if(BusinessInfo[i][Type] == 1)
{
if(strlen(BusinessInfo[i][Owner]) > 0)
{
if(strcmp(BusinessInfo[i][Owner], PlayerInfo[playerid][Name], true) == 0)
{
key = i;
return key;
}
}
}
}
else if(IsPlayerInRangeOfPoint(playerid, 150.0,BusinessInfo[i][ExitX],BusinessInfo[i][ExitY],BusinessInfo[i][ExitZ]))
{
if(BusinessInfo[i][Type] == 0)
{
if(strlen(BusinessInfo[i][Owner]) > 0)
{
if(strcmp(BusinessInfo[i][Owner], PlayerInfo[playerid][Name], true) == 0)
{
key = i;
return key;
}
}
}
}
else if(IsPlayerInRangeOfPoint(playerid, 30.0,BusinessInfo[i][EnterX],BusinessInfo[i][EnterY],BusinessInfo[i][EnterZ]))
{
if(BusinessInfo[i][Type] == 0)
{
if(strlen(BusinessInfo[i][Owner]) > 0)
{
if(strcmp(BusinessInfo[i][Owner], PlayerInfo[playerid][Name], true) == 0)
{
key = i;
return key;
}
}
}
}
}
}
return -1;
}
Re: biz plant not working. -
codExpert - 24.01.2019
this code is a mess, loggedin check in every command no need for that, slowest possible owner detection, unreadable code, what is even furnobjs doing?
Re: biz plant not working. -
TheLeech - 24.01.2019
Quote:
Originally Posted by codExpert
this code is a mess, loggedin check in every command no need for that, slowest possible owner detection, unreadable code, what is even furnobjs doing?
|
furnobjs shows all the objects into the menu, it's already defined.
new FurnObjs[683] = {
1486,1510,1517,1520,1543,1544,1664,1665,1667,14565 ,16151,3077,
3038,3028,3027,2964,2916,2915,2913,2726,2619,2616, 2614,2612,
2056,18608,2366,2414,2803,2804,2805,2806,1208,1518 ,1661,1700,
1701,1717,1718,1719,1736,1738,1745,1747,1748,1749, 1752,1771,
1778,1780,1783,1785,1786,1789,1790,1791,1792,1793, 1794,1795,
1796,1797,1798,1799,1801,1802,1808,1809,1812,1828, 1839,14651,
1840,1841,2002,2003,2013,2017,2028,2090,2091,2093, 2099,2100,
2101,2102,2103,2104,2127,2130,2131,2132,2135,2136, 2144,2147,
2149,2150,2170,2186,2190,2192,2202,2224,2225,2226, 2227,2229,
2230,2231,2232,2233,2294,2296,2297,2298,2299,2300, 2301,2302,
2332,2336,2337,2339,2340,2415,2417,2514,2515,2516, 2517,2518,
2519,2520,2521,2522,2523,2524,2525,2526,2527,2528, 2563,2564,
2565,2566,2575,2595,2596,2627,2629,2631,2632,2713, 2738,2739,
2812,2813,2815,2816,2817,2818,2819,2820,2822,2824, 2826,2827,
2828,2829,2830,2831,2832,2833,2834,2835,2836,2841, 2842,2847,
2848,2849,2850,2851,2852,2853,2854,2855,2862,2863, 2864,2865,
2868,2869,2870,14384,14446,14494,14527,14532,14604 ,14705,
14806,14861,14866,14880,14891,15039,16444,3109,306 1,3034,
3033,3032,3029,2955,2949,2948,2947,2946,2944,2945, 2911,977,
1491,1492,1493,1494,1495,1496,1497,1498,1499,1500, 1501,1502,
1504,1505,1506,1507,1508,1522,1523,1532,1533,1535, 1536,1537,
1538,1555,1556,1557,1566,1567,1569,1651,1980,2558, 2559,2560,
2561,14752,18084,2374,2377,2378,2382,2383,2392,239 4,2704,
2705,2706,2843,2844,2845,2846,18659,18660,18661,18 662,
18663,18664,18665,18666,18667,19353,19354,19355,19 356,
19357,19358,19359,19360,19361,19362,19363,19364,19 365,
19366,19367,19368,19369,19370,19371,19372,19373,19 374,
19375,19376,19377,19378,19379,19380,19381,19445,19 446,
19447,19448,19449,19450,19451,19452,19453,19454,19 455,
19456,19457,19458,19459,19460,19461,19462,19463,19 383,19384,
19385,19386,19387,19388,19389,19390,19391,19392,19 393,
19394,19395,19396,19397,19398,1985,625,626,627,628 ,630,
631,632,633,639,644,646,675,678,679,742,743,804,81 1,1361,
2001,2010,2011,2194,2195,2203,2240,2241,2242,2696, 2695,
2691,2662,2661,2660,2659,2658,2656,2655,2047,2048, 2714,
2745,3471,14467,17969,8572,8613,8614,8615,12839,12 950,
12958,13011,14387,14394,14395,14407,14409,14410,14 411,
14414,14416,14877,3964,3963,3962,3921,3497,3496,31 11,
3031,3017,2894,2707,2617,2572,2571,2357,2290,2289,
2288,2287,2286,2285,2284,2283,2282,2281,2280,2279,
2278,2277,2276,2275,2274,2273,2272,2271,2270,2269, 2267,
2266,2265,2264,2263,2262,2261,2260,2259,2257,2256, 2255,
2239,2238,2196,2179,2176,2119,2118,2117,2116,2115, 2112,
2111,2110,2109,2108,2107,2106,2105,2086,2085,2080, 2076,
2075,2074,2073,2072,2071,2069,2032,2031,2030,2029, 2026,
2023,1962,1961,1960,1892,1893,1770,1768,1766,1764, 1763,
1761,1760,1757,1756,1753,1737,1734,1731,1713,1712, 1710,
1709,1706,1703,1702,1565,15037,14862,14820,1255,16 780,
1658,936,937,941,1416,1417,1740,1741,1742,1743,174 4,
1754,1755,1758,1759,1762,1765,1767,1769,1814,1815,
1816,1817,1818,1819,1820,1821,1822,1823,2000,2007,
2014,2015,2016,2018,2019,2022,2063,2065,2066,2067,
2081,2082,2083,2084,2087,2088,2089,2094,2095,2126,
2137,2138,2139,2140,2151,2152,2153,2154,2156,2157, 2158,
2159,2160,2161,2162,2163,2164,2191,2199,2200,2204, 2208,
2210,2211,2234,2235,2236,2291,2292,2295,2304,2305, 2306,
2307,2323,2328,2329,2330,2334,2335,2338,2416,2418, 2419,
2451,2529,2530,2562,2568,2569,2570,2573,2574,2576, 2604,
2606,2608,2609,2610,2708,2737,5171,11334,14455,145 56,
14719,14720,14741,14802,14745,14805,14817,14828,19 129,
14888,15025,15026,15036,16378,2367,2368,18070,1810 2,
19892,19893,19805,19817,19818,19819,
19820,19821,19822,19823,19896,11735,11737,11733,11 732,
11714,11715,11716,11706,11705,11704
};
Re: biz plant not working. -
codExpert - 24.01.2019
PHP Code:
nearestOwnedBusiness(pid)
{
for(new i, i2=sizeof(BusinessInfo); i < i2; i++){
if( (IsPlayerInRangeOfPoint(pid, 150.0,BusinessInfo[i][EnterX],BusinessInfo[i][EnterY],BusinessInfo[i][EnterZ]) && (BusinessInfo[i][Type] == 0 || BusinessInfo[i][Type] == 1) ||
IsPlayerInRangeOfPoint(pid, 150.0,BusinessInfo[i][ExitX],BusinessInfo[i][ExitY],BusinessInfo[i][ExitZ]) && BusinessInfo[i][Type] == 0) &&
strlen(BusinessInfo[i][Owner]) > 0 && strcmp(BusinessInfo[i][Owner], PlayerInfo[pid][Name], true) == 0))
{
return i;
}
}
return -1;
}
CMD:biz(playerid, params[])
{
new string[128], param[64], amount, amount2;
if(sscanf(params, "s[64]I(-1)I(-1)", param, amount, amount2))
{
scm(playerid, COLOR_GREEN, "/biz [usage]");
scm(playerid, COLOR_GREY, " plant | edit | select |");
}
new nearestBid=nearestOwnedBusiness(playerid);
if(nearestBid==-1)return scm(playerid, COLOR_WHITE, "you arent near to any of your businesses!");
if(strcmp(param, "plant", true) == 0)
{
if(amount == (-1)) {
ShowModelSelectionMenuEx(playerid, FurnObjs, sizeof(FurnObjs), "Furniture List", 8, 16.0, 0.0, -55.0);
} else {
if(amount < 320 || amount > 35000) return scm(playerid, -1, "Invalid Object ID!");
if( GetPlayerInterior(playerid) == 0 &&
GetPlayerVirtualWorld(playerid) == 0 &&
IsInvalidObjectID(amount)) return scm(playerid, -1, "This is not a valid outdoor furniture object!");
new foundid = -1;
for(new i = 0; i < MAX_OBJECT_ARRAY; i++) {
if(ObjectList[i][oID] == amount) {
foundid=i;
break;
}
}
if(foundid == -1) return scm(playerid, -1, "Invalid Object ID!");
new Float:X, Float:Y, Float:Z, obj = 0;
GetPlayerPos(playerid, X, Y, Z);
obj = CreatePlayerObject(playerid, amount, X+1.0, Y+1.0, Z, 0.0, 0.0, 0.0, 100.0);
SetPVarInt(playerid, "FurnObject", obj);
SetPVarInt(playerid, "EditorMode", 3);
SetPVarInt(playerid, "Mute", 1);
PlayerInfo[playerid][pFurnID]=amount;
EditPlayerObject(playerid, obj);
format(string, sizeof(string),"%s selected, use the SPRINT key to navigate.", ObjectList[foundid][oName]);
scm(playerid, COLOR_WHITE, string);
}
}
else if(strcmp(param, "edit", true) == 0)
{
GetCloseBizzObject(playerid, nearestBid);
}
else if(strcmp(param, "removeall", true) == 0)
{
ShowPlayerDialog(playerid, DIALOG_BUSINESS_REMOVEALL, DIALOG_STYLE_MSGBOX,
"Remove all furniture objects",
"Are you sure you want to remove all of your current business furniture objects?", "Yes", "No");
}
return 1;
}
Re: biz plant not working. -
TheLeech - 24.01.2019
Quote:
Originally Posted by codExpert
PHP Code:
nearestOwnedBusiness(pid)
{
for(new i, i2=sizeof(BusinessInfo); i < i2; i++){
if( (IsPlayerInRangeOfPoint(pid, 150.0,BusinessInfo[i][EnterX],BusinessInfo[i][EnterY],BusinessInfo[i][EnterZ]) && (BusinessInfo[i][Type] == 0 || BusinessInfo[i][Type] == 1) ||
IsPlayerInRangeOfPoint(pid, 150.0,BusinessInfo[i][ExitX],BusinessInfo[i][ExitY],BusinessInfo[i][ExitZ]) && BusinessInfo[i][Type] == 0) &&
strlen(BusinessInfo[i][Owner]) > 0 && strcmp(BusinessInfo[i][Owner], PlayerInfo[pid][Name], true) == 0))
{
return i;
}
}
return -1;
}
CMD:biz(playerid, params[])
{
new string[128], param[64], amount, amount2;
if(sscanf(params, "s[64]I(-1)I(-1)", param, amount, amount2))
{
scm(playerid, COLOR_GREEN, "/biz [usage]");
scm(playerid, COLOR_GREY, " plant | edit | select |");
}
new nearestBid=nearestOwnedBusiness(playerid);
if(nearestBid==-1)return scm(playerid, COLOR_WHITE, "you arent near to any of your businesses!");
if(strcmp(param, "plant", true) == 0)
{
if(amount == (-1)) {
ShowModelSelectionMenuEx(playerid, FurnObjs, sizeof(FurnObjs), "Furniture List", 8, 16.0, 0.0, -55.0);
} else {
if(amount < 320 || amount > 35000) return scm(playerid, -1, "Invalid Object ID!");
if( GetPlayerInterior(playerid) == 0 &&
GetPlayerVirtualWorld(playerid) == 0 &&
IsInvalidObjectID(amount)) return scm(playerid, -1, "This is not a valid outdoor furniture object!");
new foundid = -1;
for(new i = 0; i < MAX_OBJECT_ARRAY; i++) {
if(ObjectList[i][oID] == amount) {
foundid=i;
break;
}
}
if(foundid == -1) return scm(playerid, -1, "Invalid Object ID!");
new Float:X, Float:Y, Float:Z, obj = 0;
GetPlayerPos(playerid, X, Y, Z);
obj = CreatePlayerObject(playerid, amount, X+1.0, Y+1.0, Z, 0.0, 0.0, 0.0, 100.0);
SetPVarInt(playerid, "FurnObject", obj);
SetPVarInt(playerid, "EditorMode", 3);
SetPVarInt(playerid, "Mute", 1);
PlayerInfo[playerid][pFurnID]=amount;
EditPlayerObject(playerid, obj);
format(string, sizeof(string),"%s selected, use the SPRINT key to navigate.", ObjectList[foundid][oName]);
scm(playerid, COLOR_WHITE, string);
}
}
else if(strcmp(param, "edit", true) == 0)
{
GetCloseBizzObject(playerid, nearestBid);
}
else if(strcmp(param, "removeall", true) == 0)
{
ShowPlayerDialog(playerid, DIALOG_BUSINESS_REMOVEALL, DIALOG_STYLE_MSGBOX,
"Remove all furniture objects",
"Are you sure you want to remove all of your current business furniture objects?", "Yes", "No");
}
return 1;
}
|
Error
../gamemodes/Functions.pwn(1871) : error 029: invalid expression, assumed zero
line of error
strlen(BusinessInfo[i][Owner]) > 0 && strcmp(BusinessInfo[i][Owner], PlayerInfo[pid][Name], true) == 0))
Re: biz plant not working. -
codExpert - 24.01.2019
just remove extra )
Re: biz plant not working. -
TheLeech - 24.01.2019
Quote:
Originally Posted by codExpert
just remove extra )
|
Still not showing up in game.
Re: biz plant not working. -
codExpert - 24.01.2019
well then its problem with your business owner system.
Re: biz plant not working. -
TheLeech - 24.01.2019
Quote:
Originally Posted by codExpert
well then its problem with your business owner system.
|
I decided to add a check it's showing this when I type /biz plant and shows up twice. maybe that's the reason? only one business around it's location. Figured a bit out allow was looking if it was > 0 but needs to be > -1

but now I still get two messages showing?
Re: biz plant not working. -
Pottus - 24.01.2019
Quote:
Originally Posted by codExpert
this code is a mess, loggedin check in every command no need for that, slowest possible owner detection, unreadable code, what is even furnobjs doing?
|
This is messy code with weird logic and mixed variables/pvars no wonder there is problems.