Script doesn't work
#1

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
Reply
#2

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

Please explain what the hell is the problem?
Reply
#4

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?
Reply
#5

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;
}
Reply
#6

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.
Reply
#7

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");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)