Unknown Command - 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: Unknown Command (
/showthread.php?tid=512490)
Unknown Command -
DarkLored - 11.05.2014
So i am trying to make a inventory system for my GM from scratch but the problem is i finished the command but when i try to test it ingame it doesn't work at all.
here is the code
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/i use", true))
{
new itemslot,string[128];
if(sscanf(cmdtext,"i",itemslot))
{
SendClientMessage(playerid,-1,"USAGE: /i use (itemslot).");
return 1;
}
if(itemslot == 1)
{
itemslot = pInfo[playerid][pInv1];
if(pInfo[playerid][pInv1] == 995)
{
SendClientMessage(playerid,-1,"The command works");
}
return 1;
}
return 1;
}
return 0;
}
Re: Unknown Command -
Jstylezzz - 11.05.2014
pawn Код:
if(strcmp(cmdtext, "/i use", true))
If the strings are the same, strcmp returns 0. What you do is call the command if the returned value is 1.
Try
pawn Код:
if(!strcmp(cmdtext, "/i use", true))
//rest
Placing a '!' before strcmp should work.
OR
You can place a == 0 behind it. It would look like this
pawn Код:
if (strcmp("/i use", cmdtext, true) == 0)
//rest
I hope this helps you further
Re: Unknown Command -
Beckett - 11.05.2014
I think you can't put a space in a command so try this?
pawn Код:
if(strcmp(cmdtext, "/i", true))
{
new var[5];
if(strcmp(var,"use",true) == 0)
{
// Code here
}
}
Re: Unknown Command -
DarkLored - 11.05.2014
i converted my command to ZCMD but when i type the command correct the sscanf always says the usage even if its correct.
pawn Код:
CMD:i(playerid,params[])
{
new itemslot,string[128];
new var[5];
if(strcmp(var,"use",true) == 0)
{
if(sscanf(params,"i",itemslot))
{
SendClientMessage(playerid,-1,"USAGE: /i use (itemslot).");
return 1;
}
if(itemslot == 1)
{
itemslot = pInfo[playerid][pInv1];
if(pInfo[playerid][pInv1] == 995)
{
SendClientMessage(playerid,-1,"The command works");
}
return 1;
}
return 1;
}
return 1;
}
Re: Unknown Command -
Konstantinos - 11.05.2014
pawn Код:
CMD:i(playerid,params[])
{
new option[4], itemslot; // if you add more options with more characters on them, make the size of the array longer
if (sscanf(params, "s[4]i", option, itemslot)) return SendClientMessage(playerid, -1, "USAGE: /i use (itemslot).");
if (!strcmp(option, "use", true))
{
if (itemslot == 1)
{
if(pInfo[playerid][pInv1] == 995)
{
SendClientMessage(playerid, -1, "The command works");
}
}
}
else SendClientMessage(playerid, -1, "Available options: use");
return 1;
}
Re: Unknown Command -
DarkLored - 11.05.2014
Works thank you so much +1 to all who contributed their time.