How to make a simple strcmp cmd! -
ricardo178 - 24.01.2011
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!
Re: How to make a simple strcmp cmd! -
iggy1 - 25.01.2011
Well, you shouldn't put commands inside OnFilterScriptInit. Its not realy explained well either. Eg, you could have said what strcmp does (in this case compares the command the player typed to "/vr"). I thought that might be better than just saying this is the basic format. Its good that your trying to help people, its just better if you make sure the code works before posting.
Re: How to make a simple strcmp cmd! -
alpha500delta - 25.01.2011
Failed... A command will not work under OnFilterScriptInit lol.
Did you even check the wiki before making this tutorial?
If n00bs will copy this they will get all kinda errors
Re: How to make a simple strcmp cmd! -
Gh0sT_ - 25.01.2011
ZCMD / Y_CMD is much faster then strcmp.
Re: How to make a simple strcmp cmd! -
ricardo178 - 25.01.2011
Quote:
Originally Posted by alpha500delta
Failed... A command will not work under OnFilterScriptInit lol.
Did you even check the wiki before making this tutorial?
If n00bs will copy this they will get all kinda errors
|
Ups, i just done a mistake... If you see in up of tut it is OnPlayerCommandText (Thanks for reporting and will be changed) And i don't post tuturials of thinks i don't know make
P.S: Code compile and work well! Tested by me before posting... I just didn't copy past the cmd of my test but yes made it again... It is normal make some mistakes right?
Re: How to make a simple strcmp cmd! -
alpha500delta - 25.01.2011
Actually the /vr failed a bit because it sets the vehicle's visual damage but not the smoke damage
Re: How to make a simple strcmp cmd! -
ricardo178 - 25.01.2011
It repair the whole types of damage... Not only visual!
Re: How to make a simple strcmp cmd! -
Not available - 25.01.2011
Quote:
Originally Posted by alpha500delta
Actually the /vr failed a bit because it sets the vehicle's visual damage but not the smoke damage
|
RepairVehicle repairs visual damage
along with the health.
Re: How to make a simple strcmp cmd! -
ricardo178 - 26.01.2011
Quote:
Originally Posted by Not available
RepairVehicle repairs visual damage along with the health.
|
Yeah and i have done this coz in forums, haven't there mutch tuts of this!