/give bug
#1

Hello, I got a problem with my /give command. Everything works but the berry option and I cant figure out why.
This is the code:

Код:
CMD:give(playerid, params[])
{
	new targetid, option[300], string[128];
	if(sscanf(params, "us[300]", targetid, option))
    {
        SendClientMessage(playerid, RED, "[Survival:RP] /give [ID] [OPTION]");
        SendClientMessage(playerid, COLOR_WHITE, "[Survival:RP] Options: matches,firewood,waterbottle,fishingRod,fishingNet,heroin,fish,walkietalkie,mask,cookedfish,berry,boarmeat,fruit");
        return 1;
    }
    new targetname[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
    GetPlayerName(targetid, targetname, sizeof(targetname));
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new Float:x,Float:y,Float:z;
	GetPlayerPos(playerid,x,y,z);
	new Float:tx,Float:ty,Float:tz;
	GetPlayerPos(targetid,tx,ty,tz);
	if(!IsPlayerInRangeOfPoint(playerid, 6.0, tx,ty,tz))
	return SendClientMessage(playerid, RED, "[Survival:RP] You arent close to that player");
	{
	    if(targetid == playerid) return SendClientMessage(playerid, RED, "[Survival:RP] You cant give yourself stuff");
	    {
	        if (strcmp(option, "matches", true) == 0)
	        {
	            if(PlayerInfo[playerid][pMatches] > 0)
	            {
	                PlayerInfo[playerid][pMatches] -= 1;
	                PlayerInfo[targetid][pMatches] += 1;
	                format(string, sizeof(string), "%s hands some matches to %s", sendername,targetname);
	                ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
	            }
	            else
	            {
	                SendClientMessage(playerid, RED, "[Survival:RP] You dont have any matches to give");
	            }
	        }
			if (strcmp(option, "mask", true) == 0)
			{
			    if(PlayerInfo[playerid][pMask] > 0)
			    {
			        PlayerInfo[playerid][pMask] -= 1;
			        PlayerInfo[targetid][pMask] += 1;
			        format(string, sizeof(string), "%s hands a mask to %s", sendername,targetname);
	                ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
            	}
	            else
	            {
	                SendClientMessage(playerid, RED, "[Survival:RP] You dont have any firewoods to give");
	            }
			}
			if (strcmp(option, "firewood", true) == 0)
	        {
	            if(PlayerInfo[playerid][pWood] > 0)
	            {
	                PlayerInfo[playerid][pWood] -= 1;
	                PlayerInfo[targetid][pWood] += 1;
	                format(string, sizeof(string), "%s hands fire wood to %s", sendername,targetname);
	                ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
	            }
	            else
	            {
	                SendClientMessage(playerid, RED, "[Survival:RP] You dont have any firewoods to give");
	            }
	        }
	        if (strcmp(option, "waterbottle", true) == 0)
	        {
	            if(PlayerInfo[playerid][pWaterBottle] > 0)
	            {
	                PlayerInfo[playerid][pWaterBottle] -= 1;
	                PlayerInfo[targetid][pWaterBottle] += 1;
	                format(string, sizeof(string), "%s hands a WaterBottle to %s", sendername,targetname);
	                ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
	            }
	            else
	            {
	                SendClientMessage(playerid, RED, "[Survival:RP] You dont have any WaterBottles");
	            }
	        }
	        if (strcmp(option, "fishingrod", true) == 0)
	        {
	            if(PlayerInfo[playerid][pFishingRod] > 0)
	            {
	                PlayerInfo[playerid][pFishingRod] -= 1;
	                PlayerInfo[targetid][pFishingRod] += 1;
	                format(string, sizeof(string), "%s hands a Fishing Rod to %s", sendername,targetname);
	                ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
	            }
	            else
	            {
	                SendClientMessage(playerid, RED, "[Survival:RP] You dont have a Fishing Rod");
	            }
	        }
	        if (strcmp(option, "fishingnet", true) == 0)
	        {
	            if(PlayerInfo[playerid][pFishingNet] > 0)
	            {
	                PlayerInfo[playerid][pFishingNet] -= 1;
	                PlayerInfo[targetid][pFishingNet] += 1;
	                format(string, sizeof(string), "%s hands a Fishing Net to %s", sendername,targetname);
	                ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
	            }
	            else
	            {
	                SendClientMessage(playerid, RED, "[Survival:RP] You dont have a Fishing Net");
	            }
	        }
	        if (strcmp(option, "heroin", true) == 0)
	        {
	            if(PlayerInfo[playerid][pHeroin] > 0)
	            {
	                PlayerInfo[playerid][pHeroin] -= 1;
	                PlayerInfo[targetid][pHeroin] += 1;
	                format(string, sizeof(string), "%s hands a bag of heroin to %s", sendername,targetname);
	                ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
	            }
	            else
	            {
	                SendClientMessage(playerid, RED, "[Survival:RP] You dont have any heroin");
	            }
	        }
			if  (strcmp(option, "fish", true) == 0)
			{
			    if(PlayerInfo[playerid][pFish] > 0)
			    {
			        PlayerInfo[playerid][pFish] -= 1;
	                PlayerInfo[targetid][pFish] += 1;
	                format(string, sizeof(string), "%s hands a fish to %s", sendername,targetname);
	                ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
				}
				else
				{
				    SendClientMessage(playerid, RED, "[Survival:RP] You dont have any fishes");
				}
			}
			if( strcmp(option, "walkietalkie", true) == 0)
			{
				if(PlayerInfo[playerid][pWalkieTalkie] > 0)
				{
					PlayerInfo[playerid][pWalkieTalkie] -=  1;
    				PlayerInfo[targetid][pWalkieTalkie] += 1;
        			format(string, sizeof(string), "%s hands a walkie talkie to %s", sendername,targetname);
          			ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
				}
				else
				{
					SendClientMessage(playerid, RED, "[Survival:RP] You dont have a walkie talkie");
				}
				if( strcmp(option, "cookedfish", true) == 0)
				{
					if(PlayerInfo[playerid][pFishDone] > 0)
					{
						PlayerInfo[playerid][pFishDone] -=  1;
    					PlayerInfo[targetid][pFishDone] += 1;
        				format(string, sizeof(string), "%s hands a cooked fish to %s", sendername,targetname);
          				ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
					}
					else
					{
						SendClientMessage(playerid, RED, "[Survival:RP] You dont have a cooked fish");
					}
				}
                if( strcmp(option, "berry", true) == 0)
				{
					if(PlayerInfo[playerid][pBerry] > 0)
					{
						PlayerInfo[playerid][pBerry] -=  1;
    					PlayerInfo[targetid][pBerry] += 1;
        				format(string, sizeof(string), "%s hands a berry to %s", sendername,targetname);
          				ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
					}
					else
					{
						SendClientMessage(playerid, RED, "[Survival:RP] You dont have a berry");
					}
				}
                if( strcmp(option, "boarmeat", true) == 0)
				{
					if(PlayerInfo[playerid][pBoarMeat] > 0)
					{
						PlayerInfo[playerid][pBoarMeat] -= 1;
    					PlayerInfo[targetid][pBoarMeat] += 1;
        				format(string, sizeof(string), "%s hands some boar meat to %s", sendername,targetname);
          				ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
					}
					else
					{
						SendClientMessage(playerid, RED, "[Survival:RP] You dont have any boarmeat");
					}
				}
				if( strcmp(option, "fruit", true) == 0)
				{
					if(PlayerInfo[playerid][pFruit] > 0)
					{
						PlayerInfo[playerid][pFruit] -=  1;
    					PlayerInfo[targetid][pFruit] += 1;
        				format(string, sizeof(string), "%s hands a apple to %s", sendername,targetname);
          				ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
					}
					else
					{
						SendClientMessage(playerid, RED, "[Survival:RP] You dont have a apple");
					}
				}
			}
		}
	}
	return 1;
}
This is the berry option:

Код:
if( strcmp(option, "berry", true) == 0)
				{
					if(PlayerInfo[playerid][pBerry] > 0)
					{
						PlayerInfo[playerid][pBerry] -=  1;
    					PlayerInfo[targetid][pBerry] += 1;
        				format(string, sizeof(string), "%s hands a berry to %s", sendername,targetname);
          				ProxDetector(30.0, playerid, string, COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2,COLOR_PURPLE2);
					}
					else
					{
						SendClientMessage(playerid, RED, "[Survival:RP] You dont have a berry");
					}
				}
Cant find whats wrong
Reply
#2

Oh man, you have to use tabulator (tab to indent, shift + tab to unident). Your problem lies after walkietalkie, because you don't have closing bracket there (line before "if( strcmp(option, "cookedfish", true) == 0)")
Reply
#3

Cant believe I was that blind!

Thanks m8.

repped you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)