PDA

View Full Version : command is not working...


IndependentGaming
02/08/2015, 01:39 PM
Hello, i edited the CMD:craft and if you only have the first item you need you can craft the item, but the second item is not needed how can i fix that you need both items ??


CMD:craft(playerid, params[])
{
if(getPlayerJobType(playerid) != 10 && getPlayerJob2Type(playerid) != 10)

{
SendClientMessage(playerid,COLOR_GREY," You are not a Craftsman!");
return 1;
}
if (playerData[playerid][pJailTime] > 0)
{
SendClientMessage(playerid,COLOR_GREY," You can not make things while in jail or prison!");
return 1;
}
new string[128];
if (GetPVarInt(playerid, "ArmsTimer") > 0)
{
format(string, sizeof(string), " You must wait %d seconds before crafting again.", GetPVarInt(playerid, "ArmsTimer"));
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
if(playerData[playerid][pHospital] > 0)
{
SendClientMessage(playerid, COLOR_GREY, "You can't craft whilst in Hospital.");
return 1;
}
new giveplayerid, szChoice[32], weapon, price;
if(sscanf(params, "us[32]", giveplayerid, szChoice))
{
SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
SendClientMessage(playerid, COLOR_YELLOW, "<< Available crafts >>");
SendClientMessage(playerid, COLOR_GRAD1, "Screwdriver(1000)");
SendClientMessage(playerid, COLOR_GRAD1, "Wristwatch(500)");
SendClientMessage(playerid, COLOR_GRAD1, "Tire(250)");
SendClientMessage(playerid, COLOR_GRAD1, "Firstaid");
SendClientMessage(playerid, COLOR_GRAD1, "Camera(250)");
SendClientMessage(playerid, COLOR_GRAD1, "Gps(1000)");
SendClientMessage(playerid, COLOR_GRAD1, "Parachute(50)");
SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
SendClientMessage(playerid, COLOR_GREY, "USAGE: /craft [player] [craftname]");
return 1;
}
if (IsPlayerConnected(giveplayerid))
{
if(isnull(szChoice))
{
SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
SendClientMessage(playerid, COLOR_YELLOW, "<< Available crafts >>");
SendClientMessage(playerid, COLOR_GRAD1, "Screwdriver(1000)");
SendClientMessage(playerid, COLOR_GRAD1, "Wristwatch(500)");
SendClientMessage(playerid, COLOR_GRAD1, "Tire(250)");
SendClientMessage(playerid, COLOR_GRAD1, "Firstaid");
SendClientMessage(playerid, COLOR_GRAD1, "Camera(250)");
SendClientMessage(playerid, COLOR_GRAD1, "Gps(1000)");
SendClientMessage(playerid, COLOR_GRAD1, "Parachute(50)");
SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
SendClientMessage(playerid, COLOR_GREY, "USAGE: /craft [player] [craftname]");
return 1;
}
if(strcmp(szChoice, "screwdriver", true) == 0)
{
if(playerData[playerid][pMetalBar] >= 35 || playerData[playerid][pStick] >= 1)
{
price = 35;
price = 1;
weapon = 1;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need to have 35 metalbars and 1 stick to craft a screwdriver!");
return 1;
}
}
else if(strcmp(szChoice, "wristwatch", true) == 0)
{
if(playerData[playerid][pMaterials] >= 500 || playerData[playerid][pMetalBar] >= 3)
{
price = 500;
price = 3;
weapon = 2;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need to have 500 materials and 3 metal bar's to craft a wristwatch!");
return 1;
}
}
else if(strcmp(szChoice, "tire", true) == 0)
{
if(playerData[playerid][pScrapedRim] >= 4 || playerData[playerid][pRubberScrap] >= 4)
{
price = 4;
price = 4;
weapon = 3;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need 4 scraped rims and 4 rubber scrap to craft 4 new tire's! ");
return 1;
}
}
else if(strcmp(szChoice, "firstaid", true) == 0)
{
if(playerData[playerid][pBandage] >= 7 || playerData[playerid][pSaline] >= 3)
{
price = 7;
price = 3;
weapon = 4;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need 7 bandages and 3 saline to craft a first aid kit!");
return 1;
}
}
else if(strcmp(szChoice,"camera",true) == 0)
{
if(playerData[playerid][pCameraLenses] >= 2 || playerData[playerid][pMetalBracket] >= 6)
{
price = 2;
price = 6;
weapon = 5;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need 2 camera lenses and 6 metal bracket's to craft a camera!");
return 1;
}
}
else if(strcmp(szChoice,"gps",true) == 0)
{
if(playerData[playerid][pNeedles] >= 3 || playerData[playerid][pMetalSheet] >= 3)
{
price = 3;
price = 3;
weapon = 6;
}
else
{
SendClientMessage(playerid,COLOR_GREY," you need 3 needles and 3 metal sheet's to craft a gps!");
return 1;
}
}
else if(strcmp(szChoice,"parachute",true) == 0)
{
if(playerData[playerid][pMaterials] >= 50)
{
price = 50;
weapon = 7;
}
else
{
SendClientMessage(playerid,COLOR_GREY," Not enough Materials for that!");
return 1;
}
}
}
else { SendClientMessage(playerid,COLOR_GREY," Invalid Craft name!"); return 1; }
if (ProxDetectorS(5.0, playerid, giveplayerid))
{
if(giveplayerid == playerid)
{
if(weapon != 16 && weapon != 18)
{
playerData[playerid][pMaterials] -= price;
}

switch(weapon)
{
case 1:
{
playerData[playerid][pScrewdriver]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/sellgun");
}
case 2:
{
playerData[playerid][pWristwatch]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/wristwatch");
}
case 3:
{
playerData[playerid][pTire]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/repair");
}
case 4:
{
playerData[playerid][pFirstaid]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/firstaid");
}
case 5:
{
givePlayerWeapon(playerid, 43, 50);
}
case 6:
{
playerData[playerid][pGPS]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/gps");
}
case 7:
{
givePlayerWeapon(playerid, 45, 50);
}
}
format(string, sizeof(string), "* You offered %s to buy a %s.", getPlayerName(giveplayerid), szChoice);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);

format(string, sizeof(string), "* Craftsman %s wants to sell you a %s, (type /accept craft) to buy.", getPlayerName(playerid), szChoice);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);

CraftOffer[giveplayerid] = playerid;
CraftId[giveplayerid] = weapon;
CraftMats[giveplayerid] = price;

format(CraftName[giveplayerid], 50, "%s", szChoice);

if(playerData[playerid][pAdmin] < 3) SetPVarInt(playerid, "ArmsTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_ARMSTIMER);

return 1;
}
else SendClientMessage(playerid, COLOR_GREY, "You're not near the specified player.");
}
else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

IndependentGaming
02/08/2015, 02:40 PM
Anyone ?

xVIP3Rx
02/08/2015, 03:27 PM
use "&&" instead of "||"

CMD:craft(playerid, params[])
{
if(getPlayerJobType(playerid) != 10 && getPlayerJob2Type(playerid) != 10)

{
SendClientMessage(playerid,COLOR_GREY," You are not a Craftsman!");
return 1;
}
if (playerData[playerid][pJailTime] > 0)
{
SendClientMessage(playerid,COLOR_GREY," You can not make things while in jail or prison!");
return 1;
}
new string[128];
if (GetPVarInt(playerid, "ArmsTimer") > 0)
{
format(string, sizeof(string), " You must wait %d seconds before crafting again.", GetPVarInt(playerid, "ArmsTimer"));
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
if(playerData[playerid][pHospital] > 0)
{
return SendClientMessage(playerid, COLOR_GREY, "You can't craft whilst in Hospital.");
return 1;
}
new giveplayerid, szChoice[32], weapon, price;
if(sscanf(params, "us[32]", giveplayerid, szChoice))
{
SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
SendClientMessage(playerid, COLOR_YELLOW, "<< Available crafts >>");
SendClientMessage(playerid, COLOR_GRAD1, "Screwdriver(1000)");
SendClientMessage(playerid, COLOR_GRAD1, "Wristwatch(500)");
SendClientMessage(playerid, COLOR_GRAD1, "Tire(250)");
SendClientMessage(playerid, COLOR_GRAD1, "Firstaid");
SendClientMessage(playerid, COLOR_GRAD1, "Camera(250)");
SendClientMessage(playerid, COLOR_GRAD1, "Gps(1000)");
SendClientMessage(playerid, COLOR_GRAD1, "Parachute(50)");
SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
SendClientMessage(playerid, COLOR_GREY, "USAGE: /craft [player] [craftname]");
return 1;
}
if (IsPlayerConnected(giveplayerid))
{
if(strcmp(szChoice, "screwdriver", true) == 0)
{
if(playerData[playerid][pMetalBar] >= 35 && playerData[playerid][pStick] >= 1)
{
price = 35;
price = 1;
weapon = 1;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need to have 35 metalbars and 1 stick to craft a screwdriver!");
return 1;
}
}
else if(strcmp(szChoice, "wristwatch", true) == 0)
{
if(playerData[playerid][pMaterials] >= 500 && playerData[playerid][pMetalBar] >= 3)
{
price = 500;
price = 3;
weapon = 2;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need to have 500 materials and 3 metal bar's to craft a wristwatch!");
return 1;
}
}
else if(strcmp(szChoice, "tire", true) == 0)
{
if(playerData[playerid][pScrapedRim] >= 4 && playerData[playerid][pRubberScrap] >= 4)
{
price = 4;
price = 4;
weapon = 3;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need 4 scraped rims and 4 rubber scrap to craft 4 new tire's! ");
return 1;
}
}
else if(strcmp(szChoice, "firstaid", true) == 0)
{
if(playerData[playerid][pBandage] >= 7 && playerData[playerid][pSaline] >= 3)
{
price = 7;
price = 3;
weapon = 4;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need 7 bandages and 3 saline to craft a first aid kit!");
return 1;
}
}
else if(strcmp(szChoice,"camera",true) == 0)
{
if(playerData[playerid][pCameraLenses] >= 2 && playerData[playerid][pMetalBracket] >= 6)
{
price = 2;
price = 6;
weapon = 5;
}
else
{
SendClientMessage(playerid,COLOR_GREY," You need 2 camera lenses and 6 metal bracket's to craft a camera!");
return 1;
}
}
else if(strcmp(szChoice,"gps",true) == 0)
{
if(playerData[playerid][pNeedles] >= 3 && playerData[playerid][pMetalSheet] >= 3)
{
price = 3;
price = 3;
weapon = 6;
}
else
{
SendClientMessage(playerid,COLOR_GREY," you need 3 needles and 3 metal sheet's to craft a gps!");
return 1;
}
}
else if(strcmp(szChoice,"parachute",true) == 0)
{
if(playerData[playerid][pMaterials] >= 50)
{
price = 50;
weapon = 7;
}
else
{
SendClientMessage(playerid,COLOR_GREY," Not enough Materials for that!");
return 1;
}
}
}
else { SendClientMessage(playerid,COLOR_GREY," Invalid Craft name!"); return 1; }
if (ProxDetectorS(5.0, playerid, giveplayerid))
{
if(giveplayerid == playerid)
{
if(weapon != 16 && weapon != 18)
{
playerData[playerid][pMaterials] -= price;
}

switch(weapon)
{
case 1:
{
playerData[playerid][pScrewdriver]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/sellgun");
}
case 2:
{
playerData[playerid][pWristwatch]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/wristwatch");
}
case 3:
{
playerData[playerid][pTire]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/repair");
}
case 4:
{
playerData[playerid][pFirstaid]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/firstaid");
}
case 5:
{
givePlayerWeapon(playerid, 43, 50);
}
case 6:
{
playerData[playerid][pGPS]++;
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "/gps");
}
case 7:
{
givePlayerWeapon(playerid, 45, 50);
}
}
format(string, sizeof(string), "* You offered %s to buy a %s.", getPlayerName(giveplayerid), szChoice);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);

format(string, sizeof(string), "* Craftsman %s wants to sell you a %s, (type /accept craft) to buy.", getPlayerName(playerid), szChoice);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);

CraftOffer[giveplayerid] = playerid;
CraftId[giveplayerid] = weapon;
CraftMats[giveplayerid] = price;

format(CraftName[giveplayerid], 50, "%s", szChoice);

if(playerData[playerid][pAdmin] < 3) SetPVarInt(playerid, "ArmsTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_ARMSTIMER);

return 1;
}
else SendClientMessage(playerid, COLOR_GREY, "You're not near the specified player.");
}
else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

IndependentGaming
02/08/2015, 03:35 PM
Okay whats the different?

xVIP3Rx
02/08/2015, 03:43 PM
In the script ? I replaced || with &&

this || this = this OR this.
this && this = this AND this.
as simple as that.