[Tutorial] How to make a simple strcmp cmd!
#1

Hello guys, some guys get complaines to create simple commands like a /vr one when start scripting... So i will explain how to make a simple /vr cmd for example:


You need the basic cmd format:

Put this on public OnPlayerCommandText(playerid, cmdtext[]);

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/vr", true);
Now you will put the Function code... RepairVehicle(GetPlayerVehicleID(playerid));
pawn Code:
{
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, 0xFF4444FF, "You Repaired Your Vehicle");
        return 1;
    }
    return 0;
}
Will look like this:

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/vr", true) == 0)
    {
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, 0xFF4444FF, "You Repaired Your Vehicle");
        return 1;
    }
    return 0;
}
So, i will now explain the parts:

if(strcmp(cmdtext, "/vr", true) == 0) = Basic cmd format

{ =open the script
RepairVehicle(GetPlayerVehicleID(playerid)); = This make the cmd repair the vehicle(This is the command FUNCTION)
SendClientMessage(playerid, 0xFF4444FF, "You Repaired Your Vehicle"); = This send a message to player!
return 1; = Return the value
} = Close the script

I hope this is helpfull... If you think i need to change something only replay!
Reply


Messages In This Thread
How to make a simple strcmp cmd! - by ricardo178 - 24.01.2011, 22:02
Re: How to make a simple strcmp cmd! - by iggy1 - 25.01.2011, 12:27
Re: How to make a simple strcmp cmd! - by alpha500delta - 25.01.2011, 14:03
Re: How to make a simple strcmp cmd! - by Gh0sT_ - 25.01.2011, 16:16
Re: How to make a simple strcmp cmd! - by ricardo178 - 25.01.2011, 17:13
Re: How to make a simple strcmp cmd! - by alpha500delta - 25.01.2011, 20:17
Re: How to make a simple strcmp cmd! - by ricardo178 - 25.01.2011, 20:27
Re: How to make a simple strcmp cmd! - by Not available - 25.01.2011, 21:48
Re: How to make a simple strcmp cmd! - by ricardo178 - 26.01.2011, 07:05

Forum Jump:


Users browsing this thread: 1 Guest(s)