Commands help - 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: Commands help (
/showthread.php?tid=473502)
Deleted. -
iFiras - 03.11.2013
Deleted.
Re: Commands help -
[HK]Ryder[AN] - 03.11.2013
Use sscanf
Deleted. -
iFiras - 03.11.2013
Deleted.
Re: Commands help -
[HK]Ryder[AN] - 03.11.2013
I understand you completely and sscanf can work.. Show me your existing code.
-----------------
This forum requires that you wait 240 seconds between posts. Please try again in 39 seconds.
*When did it reach 240 seconds? damnnnn*
Re: Commands help -
Jony_Cruze - 03.11.2013
pawn Код:
COMMAND:takedrugs(playerid,params[])
{
new idx = 0;
new tmp[64];
tmp = strtok(params,idx);
if(!strlen(tmp)) { SendClientMessage(playerid,COLOR_LIGHTRED,"FOLOSESTE: /takedrugs [weed/heroin/coke]"); return 1; }
if(strcmp(tmp,"coke",true) == 0)
{
if(HasItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_COKE,1))
{
SendEmote(playerid,"face o linie de cocaina si incepe sa o traga.");
RemoveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_COKE,1);
heroin[playerid] = 1;
heroin_stage[playerid] = 1;
heroin_expire[playerid] = 5;
SetPlayerWeather(playerid,heroin_stages[heroin_stage[playerid]]);
new adic = random(100);
if(adic > 75 && !CharacterInfo[playerid][active_character[playerid]][cAddiction])
{
SendClientMessage(playerid,COLOR_YELLOW,"Ai devenit dependent de cocaina.");
CharacterInfo[playerid][active_character[playerid]][cAddiction] = DRUG_COKE;
CharacterInfo[playerid][active_character[playerid]][cAddictionLevel] = 20;
}
if(CharacterInfo[playerid][active_character[playerid]][cAddiction]) { CharacterInfo[playerid][active_character[playerid]][cAddictionLevel] ++; addiction_runtime[playerid] = 600; }
return 1;
}
else
{
SendClientMessage(playerid,COLOR_GREY,"Nu ai cocaina.");
return 1;
}
}
if(strcmp(tmp,"heroin",true) == 0)
{
if(HasItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_HEROIN,1))
{
SendEmote(playerid,"scoate o seringa cu heroina si incepe sa se injecteze.");
RemoveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_HEROIN,1);
heroin[playerid] = 1;
heroin_stage[playerid] = 1;
heroin_expire[playerid] = 5;
SetPlayerWeather(playerid,heroin_stages[heroin_stage[playerid]]);
new adic = random(50);
if(adic > 40 && !CharacterInfo[playerid][active_character[playerid]][cAddiction])
{
SendClientMessage(playerid,COLOR_YELLOW,"Ai devenit dependent de heroina.");
CharacterInfo[playerid][active_character[playerid]][cAddiction] = DRUG_HEROIN;
CharacterInfo[playerid][active_character[playerid]][cAddictionLevel] = 10;
}
if(CharacterInfo[playerid][active_character[playerid]][cAddiction]) { CharacterInfo[playerid][active_character[playerid]][cAddictionLevel] ++; addiction_runtime[playerid] = 600; }
return 1;
}
else
{
SendClientMessage(playerid,COLOR_GREY,"Nu ai heroina.");
return 1;
}
}
if(strcmp(tmp,"weed",true) == 0)
{
if(HasItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_WEED,1))
{
SendEmote(playerid,"scoate o bricheta si aprinde un joint.");
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_SMOKE_CIGGY);
RemoveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_WEED,1);
weed[playerid] = 1;
return 1;
}
else
{
SendClientMessage(playerid,COLOR_GREY,"Nu ai iarba la tine.");
return 1;
}
}
SendClientMessage(playerid,COLOR_GREY,"Obiect neidentificat.");
return 1;
}
i don't now your your script ... but i give you a simple command ..
Re: Commands help -
[HK]Ryder[AN] - 03.11.2013
Now now, that wasn't sscanf.. here is a code i just hacked up in a couple of minutes.. not tested
Don't mind the loose indentation, typed directly here.
pawn Код:
CMD:weed(playerid, params[])
{
new whathewants[15];
if (sscanf(params, "s[15]", whathewants))
{
return SendClientMessage(playerid, 0xFF0000AA, "Usage: /weed [collect/use/sell]");
}
if(!strcmp("collect", whathewants))
{
//code
}
if(!strcmp("use", whathewants))
{
//code
} if(!strcmp("take", whathewants))
{
//code
}
return 1;
}
Deleted. -
iFiras - 03.11.2013
Deleted.
Re: Commands help -
Konstantinos - 03.11.2013
I know it was solved but this can be done without sscanf and it's actually much better.
pawn Код:
CMD:weed( playerid, params[ ] )
{
if( isnull( params ) ) SendClientMessage(playerid, 0xFF0000AA, "Usage: /weed [collect/use/sell]");
else
{
if( !strcmp( params, "collect" ) )
{
//code
}
else if( !strcmp( params, "use" ) )
{
//code
}
else if( !strcmp( params, "sell" ) )
{
//code
}
else SendClientMessage(playerid, 0xFF0000AA, "Usage: /weed [collect/use/sell]");
}
return 1;
}