2 Commands have a problem. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: 2 Commands have a problem. (
/showthread.php?tid=655049)
2 Commands have a problem. -
DavidGravelli - 12.06.2018
I made 2 commands /mask, sellbusiness
the mask have a problem that's when i bought a mask from 24/7 then i type /mask it says you put the mask off and when i type it again it says you don't have a mask. I really don't know what's the problem.
I want the mask command to be work like if you bought a mask you can toggle it on/off here is the codes:
pawn Код:
CMD:mask(playerid, params[])
{
if(pInfo[playerid][pMask] == 0)
return SendClientMessage(playerid, -1, "You don't have a mask");
new string[128];
switch (pInfo[playerid][pMask])
{
case 0:
{
SendClientMessage(playerid, -1, "You have put a mask on.");
pInfo[playerid][pMask] = 1;
}
case 1:
{
SendClientMessage(playerid, -1, "You have put a mask off.");
pInfo[playerid][pMask] = 0;
}
}
return 1;
}
/sellbusiness is that when you bought a biz and you want to sell it its say you are not near a biz or this is not your business.
Codes:
pawn Код:
CMD:sellbusiness(playerid, params[])
{
new bool:biz = false;
for(new i = 1; i < MAX_BIZ; i++)
{
if (IsPlayerInRangeOfPoint(playerid, 1.0, biz_info[i][biz_pos_entrance][0], biz_info[i][biz_pos_entrance][1], biz_info[i][biz_pos_entrance][2]))
{
if (isequal(pName(playerid), biz_info[i][biz_name], true))
{
biz = true;
GivePlayerMoney(playerid, biz_info[i][biz_price]);
new szString[256];
biz_info[i][biz_owner] = EOS;
format(szString, sizeof szString, "FOR SALE!\nBUSINESS TYPE: %s BUSINESS ID: %i\nPRICE: $%d BUY NOW!", BizTypeFormat(biz_info[i][biz_type]), i, biz_info[i][biz_price]);
UpdateDynamic3DTextLabelText(biz_info[i][biz_text3d], 0x00FF00AA, szString);
return SCM(playerid, -1, "Done! You have sold your business.");
}
}
}
if (!biz)
return SCM(playerid, -1, "You are not near a business or this is not your business.");
return 1;
}
Re: 2 Commands have a problem. -
GTLS - 12.06.2018
Quote:
Originally Posted by DavidGravelli
I made 2 commands /mask, sellbusiness
pawn Код:
CMD:mask(playerid, params[]) { if(pInfo[playerid][pMask] == 0) return SendClientMessage(playerid, -1, "You don't have a mask");
new string[128]; switch (pInfo[playerid][pMask]) { case 0: { SendClientMessage(playerid, -1, "You have put a mask on."); pInfo[playerid][pMask] = 1; } case 1: { SendClientMessage(playerid, -1, "You have put a mask off."); pInfo[playerid][pMask] = 0; } } return 1; }
|
You can not use pMask Variable for both Mask On/Off and Mask acquired. You can use PVars to check if he has mask on or off.
PHP код:
switch (GetPVarInt(playerid, "PlayerMask"))
{
case 0:
{
SendClientMessage(playerid, -1, "You have put a mask on.");
SetPVarInt(playerid, "PlayerMask", 1);
}
case 1:
{
SendClientMessage(playerid, -1, "You have put a mask off.");
SetPVarInt(playerid, "PlayerMask", 0);
}
}
Quote:
Originally Posted by DavidGravelli
/sellbusiness is that when you bought a biz and you want to sell it its say you are not near a biz or this is not your business.
Codes:
pawn Код:
CMD:sellbusiness(playerid, params[]) { new bool:biz = false;
for(new i = 1; i < MAX_BIZ; i++) { if (IsPlayerInRangeOfPoint(playerid, 1.0, biz_info[i][biz_pos_entrance][0], biz_info[i][biz_pos_entrance][1], biz_info[i][biz_pos_entrance][2])) { if (isequal(pName(playerid), biz_info[i][biz_name], true)) { biz = true;
GivePlayerMoney(playerid, biz_info[i][biz_price]);
new szString[256]; biz_info[i][biz_owner] = EOS; format(szString, sizeof szString, "FOR SALE!\nBUSINESS TYPE: %s BUSINESS ID: %i\nPRICE: $%d BUY NOW!", BizTypeFormat(biz_info[i][biz_type]), i, biz_info[i][biz_price]); UpdateDynamic3DTextLabelText(biz_info[i][biz_text3d], 0x00FF00AA, szString);
return SCM(playerid, -1, "Done! You have sold your business."); } } }
if (!biz) return SCM(playerid, -1, "You are not near a business or this is not your business.");
return 1; }
|
1> IDK if you business IDs starts from 1 or zero. But you have started the loop from 1. So ID 0 will be skipped if Biz IDs starts from 0.
2>You are using isequal function from strlib, and according to its syntax, you dont have to add true at the end but, .ignorecase = true. Try that..
3> You are checking pName with Biz_Name. I hope Biz_Name stores Owner's name not the business's own name for this to work. (Which in your case Biz_Owner stores owners name.)
PHP код:
biz_info[i][biz_owner] //This variable stores Owner's name. So use this inside isequal