Help me create a simple command
#1

Hi, I would like to ask you guys to help me into creating a simple command using ZCMD and sscanf, I want it to be like: /usedrugs [drugname] and then there's like 3 drug types, let's say weed, cocaine and heroine so If the player typed /usedrugs weed then the command will be assigned a different code, but if he typed /usedrugs cocaine another code and so on, please help me I'm new.
I will +Rep.
Reply
#2

I hope I helped!>

pawn Код:
CMD:usedrugs(playerid, params[])
{
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "You're not even connected to the server.");
    new drugsname[32];
    if(sscanf(params,"s[32]",drugsname))
    {
        SendClientMessage(playerid, -1, "USAGE: /usedrugs [drugname]");
        SendClientMessage(playerid, -1, "CHOICES: Cocaine, Heroine, Weed."); // Add more if you want.
   
        return 1;
    }
    if(strcmp(drugsname, "cocaine", true) == 0)
    {
   
        // your code
   
    }
    if(strcmp(drugsname, "weed", true) == 0)
    {

        // your code

    }
    if(strcmp(drugsname, "heroine", true) == 0)
    {

        // your code

    }
   
    return 1;
 }
Any feedback would be appreciated
Reply
#3

Thank you so much. You really helped me.
+repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)