PDA

View Full Version : DEFAULT CMD AND PARAMS


Pearson
15/12/2016, 05:27 PM
Hello.
Heres my command.

if(strcmp(cmd, "/createhouse", true) == 0)
{
if(Player[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GRAD1, ""servn" Tqven Ar Gaqvt Am Comandis Gamoyenebis Ufleba !");
new price, interiorid, houseid, Float:X, Float:Y, Float:Z, Float:A, check = 0;
if(sscanf(cmdtext, "dd", price, interiorid))
{
SendClientMessage(playerid, COLOR_GRAD1, "{00C0FF}[INFO] Daxmareba: {FFFFFF} /createhouse [price] [interior id]");
SendClientMessage(playerid, COLOR_GRAD2, "{00C0FF}[INFO] Daxmareba: {FFFFFF} /viewinterior [1-31]");
return 1;
}
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
for(new i = 1; i < sizeof(HouseInfo); i++)
{
if(HouseInfo[i][hCreated] == 0)
{
check = 1;
houseid = i;
break;
}
}
if(!check) return SendClientMessage(playerid, COLOR_GRAD2, " 1000/1000 houses have already been created !");

HouseInfo[houseid][hOutsideX] = X;
HouseInfo[houseid][hOutsideY] = Y;
HouseInfo[houseid][hOutsideZ] = Z;
HouseInfo[houseid][hOutsideA] = A;
HouseInfo[houseid][hCreated] = 1;
HouseInfo[houseid][hValue] = price;
strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
strins(HouseInfo[houseid][hTag], "House", 0);
SetHouseInterior(houseid, interiorid);
if(HouseInfo[houseid][hOutsidePickup]) { DestroyDynamicPickup(HouseInfo[houseid][hOutsidePickup]); }
HouseInfo[houseid][hOutsidePickup] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
new string3[250];
format(string3, sizeof(string3), "Saxli Iyideba!\nDaweret /buyhouse Rom Sheidzinot, \nFasi: -C- %d", houseid, HouseInfo[houseid][hValue]);
if(HouseInfoText3D[houseid]) { Delete3DTextLabel(HouseInfoText3D[houseid]); }
HouseInfoText3D[houseid] = Create3DTextLabel(string3, COLOR_HOUSETEXT, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]+0.88, 20.0, 0, 1);
Update3DTextLabelText(HouseInfoText3D[houseid], COLOR_HOUSETEXT, string3);
new stringovichi[123];
format(stringovichi, sizeof(stringovichi), ""servn" Shen Gaakete Saxli ID:%d, Fasi: %d, interiorid %d", houseid, price, interiorid);
SendClientMessage(playerid, COLOR_GRAD1, stringovichi);
return 1;
}
if(strcmp(cmd, "/deletehouse", true) == 0)
{
if(Player[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GRAD1, ""servn" Tqven Ar Gaqvt Am Comandis Gamoyenebis Ufleba !");
new houseid, iliayleia[128];
if(sscanf(cmdtext, "ds[128]", houseid, iliayleia))
{
SendClientMessage(playerid, COLOR_GRAD1, "{00C0FF}[INFO] Daxmareba: {FFFFFF} /deletehouse [houseid] [confirm]");
return 1;
}
if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, " Es Saxli Ar Aris Gaketebuli !");
if(strcmp(iliayleia, "confirm", true) == 0)
{
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(strcmp(HouseInfo[houseid][hOwner], Name(i)) == 0 && Player[i][pSaxlid] == houseid)
{
SendClientMessage(i, COLOR_LIGHTBLUE, "** Sheni Saxli Washala Administratorma");
Player[i][pSaxlid] = 0;
}
}
}
strmid(HouseInfo[houseid][hOwner], " ", 0, strlen("None"), 255);
Delete3DTextLabel(HouseInfoText3D[houseid]);
HouseInfo[houseid][hCreated] = 0;
HouseInfo[houseid][hOwned] = 0;
HouseInfo[houseid][hValue] = 0;
HouseInfo[houseid][hOutsideX] = 0;
HouseInfo[houseid][hOutsideY] = 0;
HouseInfo[houseid][hOutsideZ] = 0;
HouseInfo[houseid][hOutsideA] = 0;
HouseInfo[houseid][hInsideX] = 0;
HouseInfo[houseid][hInsideY] = 0;
HouseInfo[houseid][hInsideZ] = 0;
HouseInfo[houseid][hInsideA] = 0;
HouseInfo[houseid][hInterior] = 0;
HouseInfo[houseid][hLocked] = 0;
HouseInfo[houseid][hGun1] = 0;
HouseInfo[houseid][hGun2] = 0;
HouseInfo[houseid][hGun3] = 0;
HouseInfo[houseid][hGun4] = 0;
strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
strins(HouseInfo[houseid][hTag], "House", 0);
HouseInfo[houseid][hLevel] = 0;
if(HouseInfo[houseid][hOutsidePickup]) { DestroyDynamicPickup(HouseInfo[houseid][hOutsidePickup]); }
format(iliayleia, sizeof(iliayleia), " Shen Warmatebit Washale Saxli IS:%d !", houseid);
SendClientMessage(playerid, COLOR_GRAD1, iliayleia);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "{00C0FF}[INFO] Daxmareba: {FFFFFF} /deletehouse [houseid] [confirm]");
format(iliayleia, sizeof(iliayleia), " Darwmunebuli Xart Rom Gidnat Am Saxlis Washla? ID: %d?", houseid);
SendClientMessage(playerid, COLOR_GRAD2, iliayleia);
return 1;
}
return 1;
}
if(strcmp(cmd, "/buyhouse", true) == 0)
{
if(Player[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GRAD1, ""servn" Tqven Ar Gaqvt Am Comandis Gamoyenebis Ufleba !");
new houseid, iliayleia[128];
if(sscanf(cmdtext, "ds[128]", houseid, iliayleia))
{
SendClientMessage(playerid, COLOR_GRAD1, "{00C0FF}[INFO] Daxmareba: {FFFFFF} /deletehouse [houseid] [confirm]");
return 1;
}
if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, " Es Saxli Ar Aris Gaketebuli !");
if(strcmp(iliayleia, "confirm", true) == 0)
{
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
if(strcmp(HouseInfo[houseid][hOwner], Name(i)) == 0 && Player[i][pSaxlid] == houseid)
{
SendClientMessage(i, COLOR_LIGHTBLUE, "** Sheni Saxli Washala Administratorma");
Player[i][pSaxlid] = 0;
}
}
}
strmid(HouseInfo[houseid][hOwner], " ", 0, strlen("None"), 255);
Delete3DTextLabel(HouseInfoText3D[houseid]);
HouseInfo[houseid][hCreated] = 0;
HouseInfo[houseid][hOwned] = 0;
HouseInfo[houseid][hValue] = 0;
HouseInfo[houseid][hOutsideX] = 0;
HouseInfo[houseid][hOutsideY] = 0;
HouseInfo[houseid][hOutsideZ] = 0;
HouseInfo[houseid][hOutsideA] = 0;
HouseInfo[houseid][hInsideX] = 0;
HouseInfo[houseid][hInsideY] = 0;
HouseInfo[houseid][hInsideZ] = 0;
HouseInfo[houseid][hInsideA] = 0;
HouseInfo[houseid][hInterior] = 0;
HouseInfo[houseid][hLocked] = 0;
HouseInfo[houseid][hGun1] = 0;
HouseInfo[houseid][hGun2] = 0;
HouseInfo[houseid][hGun3] = 0;
HouseInfo[houseid][hGun4] = 0;
strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
strins(HouseInfo[houseid][hTag], "House", 0);
HouseInfo[houseid][hLevel] = 0;
if(HouseInfo[houseid][hOutsidePickup]) { DestroyDynamicPickup(HouseInfo[houseid][hOutsidePickup]); }
format(iliayleia, sizeof(iliayleia), " Shen Warmatebit Washale Saxli IS:%d !", houseid);
SendClientMessage(playerid, COLOR_GRAD1, iliayleia);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "{00C0FF}[INFO] Daxmareba: {FFFFFF} /deletehouse [houseid] [confirm]");
format(iliayleia, sizeof(iliayleia), " Darwmunebuli Xart Rom Gidnat Am Saxlis Washla? ID: %d?", houseid);
SendClientMessage(playerid, COLOR_GRAD2, iliayleia);
return 1;
}
return 1;
}

But the output is only INFo from params :)

Jefff
15/12/2016, 06:38 PM
if(sscanf(cmdtext[12], "dd", price, interiorid)) // 12 means strlen("/createhouse")
show how are you calling 'cmd' in this if(strcmp(cmd, "/createhouse", true) == 0) its strtok or sscanf too?

Pearson
15/12/2016, 07:04 PM
if(sscanf(cmdtext[12], "dd", price, interiorid)) // 12 means strlen("/createhouse")
show how are you calling 'cmd' in this if(strcmp(cmd, "/createhouse", true) == 0) its strtok or sscanf too?
I'm Not Using Any 'cmd' engine like zcmd...
I'm Just Using PAWN-s Simple command system. and i wanted to use sscanf in commands.
new cmd[20];

Jefff
15/12/2016, 11:36 PM
under that xd how you storing /createhouse into cmd

Logic_
16/12/2016, 10:55 AM
Some tips:

1. Don't use 'attention seeking' titles, this means you may not use caps
2. Use informative titles
3. Use the 'modern' functions.

Use ZCMD + sscanf + definitions instead of strcmp + strtok and unnecessary codes.

Example code:

#define MAX_HOUSES 1000

CMD:createhouse(playerid, params[])
{
if(admin == 0) return SendClientMessage(................);
if(houses >= MAX_HOUSES) return SendClientMessage(............);
if(sscanf(params, "dd", housetype, interior)) return SendClientMessage(...............);
return 1;
}