SA-MP Forums Archive
Script doesn't work - 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: Script doesn't work (/showthread.php?tid=639375)



Script doesn't work - TonyCan - 16.08.2017

PHP код:
CMD:additem(playerid,params[])
{
new 
items[32], slotid;
for(new 
=0;i<MAX_BOXS;i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,BoxInfo[i][xPos],BoxInfo[i][yPos],BoxInfo[i][zPos]))
{
if(
sscanf(params"us[32]",items,slotid)) return SCM(playeridCOLOR_WHITE" /additem [ item ] [ slot ] ");
if(
strcmp(items"burger"true))
{
if(
PlayerHasItem(playerid,"Burger"))
{
BoxInfo[i][Item][slotid] = BurgerItem;
RemoveItem(playerid,"Burger",1);
PlayerInfo[playerid][pSlotu] --;
}
else{
SCM(playerid,COLOR_RED,"You don't have Burger");}
return 
1;
}
else if(
strcmp(items"pizza"true))
{
if(
PlayerHasItem(playerid,"Pizza"))
{
BoxInfo[i][Item][slotid] = PizzaItem;
RemoveItem(playerid,"Pizza",1);
PlayerInfo[playerid][pSlotu] --;
}
else{
SCM(playerid,COLOR_RED,"You don't have Pizza");}
return 
1;
}
SaveThisBox(i);
}
}
return 
1;

Please help me fix it


Re: Script doesn't work - HoussemGaming - 16.08.2017

Quote:
Originally Posted by Manuel550
Посмотреть сообщение
Mate who scripted this?
Replace the );} with ); lmao.
You wrong lol


Re: Script doesn't work - SyS - 17.08.2017

Please explain what the hell is the problem?


Re: Script doesn't work - TonyCan - 17.08.2017

Quote:
Originally Posted by SyS
Посмотреть сообщение
Please explain what the hell is the problem?
It does not work, I can not add burger or pizza to the box
Is it wrong?


Re: Script doesn't work - 10MIN - 17.08.2017

I think this should work: (poor identation because of COPY-PASTE)
Код:
CMD:additem(playerid,params[])
{
new items[32], slotid;
if(sscanf(params, "s[32]d",items,slotid)) return SCM(playerid, COLOR_WHITE, " /additem [ item ] [ slot ] "); //You placed the parameters in format wrong... Also don't put sscanf in a loop (it would generate you, hmm, like MAX_BOXS SCMs)
for(new i =0;i<MAX_BOXS;i++)
{
if(IsPlayerInRangeOfPoint(playerid,2,BoxInfo[i][xPos],BoxInfo[i][yPos],BoxInfo[i][zPos]))
{
if(strcmp(items, "burger", true))
{
if(PlayerHasItem(playerid,"Burger"))
{
BoxInfo[i][Item][slotid] = BurgerItem;
RemoveItem(playerid,"Burger",1);
PlayerInfo[playerid][pSlotu] --;
}
else{SCM(playerid,COLOR_RED,"You don't have Burger");}
return 1;
}
else if(strcmp(items, "pizza", true))
{
if(PlayerHasItem(playerid,"Pizza"))
{
BoxInfo[i][Item][slotid] = PizzaItem;
RemoveItem(playerid,"Pizza",1);
PlayerInfo[playerid][pSlotu] --;
}
else{SCM(playerid,COLOR_RED,"You don't have Pizza");}
return 1;
}
SaveThisBox(i);
}
}
return 1;
}



Re: Script doesn't work - TonyCan - 18.08.2017

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
I think this should work: (poor identation because of COPY-PASTE)
Код:
CMD:additem(playerid,params[])
{
new items[32], slotid;
if(sscanf(params, "s[32]d",items,slotid)) return SCM(playerid, COLOR_WHITE, " /additem [ item ] [ slot ] "); //You placed the parameters in format wrong... Also don't put sscanf in a loop (it would generate you, hmm, like MAX_BOXS SCMs)
for(new i =0;i<MAX_BOXS;i++)
{
if(IsPlayerInRangeOfPoint(playerid,2,BoxInfo[i][xPos],BoxInfo[i][yPos],BoxInfo[i][zPos]))
{
if(strcmp(items, "burger", true))
{
if(PlayerHasItem(playerid,"Burger"))
{
BoxInfo[i][Item][slotid] = BurgerItem;
RemoveItem(playerid,"Burger",1);
PlayerInfo[playerid][pSlotu] --;
}
else{SCM(playerid,COLOR_RED,"You don't have Burger");}
return 1;
}
else if(strcmp(items, "pizza", true))
{
if(PlayerHasItem(playerid,"Pizza"))
{
BoxInfo[i][Item][slotid] = PizzaItem;
RemoveItem(playerid,"Pizza",1);
PlayerInfo[playerid][pSlotu] --;
}
else{SCM(playerid,COLOR_RED,"You don't have Pizza");}
return 1;
}
SaveThisBox(i);
}
}
return 1;
}
Thanks, it worked.


Re: Script doesn't work - Ghazal - 19.08.2017

Quote:
Originally Posted by Manuel550
Посмотреть сообщение
Mate who scripted this?
Replace the );} with ); lmao.
Just posting so you understand why you're wrong,
pawn Код:
else{SCM(playerid,COLOR_RED,"You don't have Pizza");}
the } at the end of the line ends the else statement. It is exactly the same like
pawn Код:
else
{
    SCM(playerid,COLOR_RED,"You don't have Pizza");
}