#include <core> #include <float> #include <string> #include <file> #include <time> #include <datagram> #include <a_players> #include <a_vehicles> #include <a_objects> #include <a_sampdb> public OnPlayerCommandText(playerid, cmdtext[]) // if a player writes command { // callback starts. //LAW if (strcmp("/police", cmdtext, true, 10) == 0) // if a player writes /police { // if he writes, start these functions: GivePlayerWeapon(playerid, 22, 10000); GivePlayerWeapon(playerid, 3, 1); GivePlayerWeapon(playerid, 22, 10000); GivePlayerWeapon(playerid, 41, 10000); } { if (strcmp("/swat", cmdtext, true, 10) == 0) // if a player writes /swat GivePlayerWeapon(playerid, 31, 10000); GivePlayerWeapon(playerid, 27, 10000); GivePlayerWeapon(playerid, 24, 10000); GivePlayerWeapon(playerid, 17, 10000); } { if (strcmp("/ff", cmdtext, true, 10) == 0) // if a player writes /ff GivePlayerWeapon(playerid, 42, 10000); } { if (strcmp("/whore", cmdtext, true, 10) == 0) // if a player writes /whore GivePlayerWeapon(playerid, 10, 1); GivePlayerWeapon(playerid, 11, 1); GivePlayerWeapon(playerid, 12, 1); GivePlayerWeapon(playerid, 13, 1); } { if (strcmp("/hitman", cmdtext, true, 10) == 0) // if a player writes /hitman GivePlayerWeapon(playerid, 34, 10000); } { if (strcmp("/terrorist", cmdtext, true, 10) == 0) // if a player writes /terrorist GivePlayerWeapon(playerid, 35, 10000); GivePlayerWeapon(playerid, 8, 1); GivePlayerWeapon(playerid, 30, 10000); } { if (strcmp("/maniac", cmdtext, true, 10) == 0) // if a player writes /maniac GivePlayerWeapon(playerid, 9, 10000); } { if (strcmp("/photographer", cmdtext, true, 10) == 0) // if a player writes /photographer GivePlayerWeapon(playerid, 43, 10000); // If he writes, Give player police weapon's return 1; // return true. } // we ended this command's functions. return 0; // return false because there is a true above. } // we ended this callback's functions.
Look for 'GivePlayerWeapon' anywhere else in your script other than the one you posted above.
|
public OnPlayerCommandText(playerid, cmdtext[]) // if a player writes a command
{ // callback starts.
//< ... other commands ... >
if (strcmp("/terrorist", cmdtext, true, 10) == 0) //if the command is /terrorist then do this:
{ //bracket starts above code, after check
GivePlayerWeapon(playerid, 35, 10000);
GivePlayerWeapon(playerid, 8, 1);
GivePlayerWeapon(playerid, 30, 10000);
return 1; //command was successful and your script can end here
} //bracket ends after the code, command /terrorist ends here
//< ... other commands ... >
return 0; //search for commands ends, no command found
} //callback ends.
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[]) // if a player writes command
{
if (strcmp("/police", cmdtext, true, 7) == 0) // if a player writes /police
{
GivePlayerWeapon(playerid, 22, 10000);
GivePlayerWeapon(playerid, 3, 1);
GivePlayerWeapon(playerid, 22, 10000);
GivePlayerWeapon(playerid, 41, 10000);
return 1;
}
if (strcmp("/swat", cmdtext, true, 5) == 0) // if a player writes /swat
{
GivePlayerWeapon(playerid, 31, 10000);
GivePlayerWeapon(playerid, 27, 10000);
GivePlayerWeapon(playerid, 24, 10000);
GivePlayerWeapon(playerid, 17, 10000);
return 1;
}
if (strcmp("/ff", cmdtext, true, 3) == 0) // if a player writes /ff
{
GivePlayerWeapon(playerid, 42, 10000);
return 1;
}
if (strcmp("/whore", cmdtext, true, 6) == 0) // if a player writes /whore
{
GivePlayerWeapon(playerid, 10, 1);
GivePlayerWeapon(playerid, 11, 1);
GivePlayerWeapon(playerid, 12, 1);
GivePlayerWeapon(playerid, 13, 1);
return 1;
}
if (strcmp("/hitman", cmdtext, true, 7) == 0) // if a player writes /hitman
{
GivePlayerWeapon(playerid, 34, 10000);
return 1;
}
if (strcmp("/terrorist", cmdtext, true, 10) == 0) // if a player writes /terrorist
{
GivePlayerWeapon(playerid, 35, 10000);
GivePlayerWeapon(playerid, 8, 1);
GivePlayerWeapon(playerid, 30, 10000);
return 1;
}
if (strcmp("/maniac", cmdtext, true, 7) == 0) // if a player writes /maniac
{
GivePlayerWeapon(playerid, 9, 10000);
return 1;
}
if (strcmp("/photographer", cmdtext, true, 13) == 0) // if a player writes /photographer
{
GivePlayerWeapon(playerid, 43, 10000);
return 1;
}
return 0;
} // we ended this callback's functions.