Shortcuts on input - 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: Shortcuts on input (
/showthread.php?tid=649569)
Shortcuts on input -
NealPeteros - 11.02.2018
So I'm trying to create a command
PHP код:
CMD:createeffect(playerid, params[])
{
new id, effect[15];
if(sscanf(params, "r,s[15]", id, effect))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /createeffect [PON/id] [fire/lightning]");
return 1;
}
if(strcmp(effect, "fire", true) == 0)
{
CreateEffect(id, 1);
}
return 1;
}
Is there any way a player can just write "f", "fi", or "fir" instead of the whole word "fire"?
Re: Shortcuts on input -
Gameluner - 11.02.2018
Код:
CMD:createeffect(playerid, params[])
{
new id, effect[15];
if(sscanf(params, "r,s[15]", id, effect))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /createeffect [PON/id] [fire/lightning]");
return 1;
}
if(strcmp(effect, "fire", true) == 0 || strcmp(effect,"f",true) == 0)
{
CreateEffect(id, 1);
}
return 1;
}
This should work
Re: Shortcuts on input -
NealPeteros - 11.02.2018
Awesome, thanks!
Re: Shortcuts on input -
RoboN1X - 11.02.2018
The answer above will compare if you entered either "fire" or "f" but no "fi" or "fir"
use
strfind instead
Код:
if(strfind("fire", effect, true) == 0)
Re: Shortcuts on input -
Dayrion - 11.02.2018
Quote:
Originally Posted by NealPeteros
PHP код:
if(sscanf(params, "r,s[15]", id, effect))
|
You shouldn't use a comma there. It should be
PHP код:
if(sscanf(params, "rs[15]", id, effect))