12.06.2014, 17:10
Please anyone tell me that how i can script campare string fucntion
CMD:key(pid, arg[])
{
if(IsPlayerInAnyVehicle(pid))
{
new vehicleid = GetPlayerVehicleID(pid);
new choice[5], engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(sscanf(arg, "s[5]", choice)) return SendMessage(pid, 2, "/key [off][on][acc]");
if(!strcmp(choice, "off"))
{
There's strcmp which already exists.
But if you want to script your own, you have to do a loop through each cell of both string and comparing if the cell x from string 1 equals to the cell x from string 2. If it does, simply use "continue;". If it doesn't, use "return false;" for example or return anything you want when the strings aren't identic. |
stock IsPlayerNameHasPGInside(playerid)
{
new playername[MAX_PLAYER_NAME+1], teamtag[5];
GetPlayerName(playerid, playername, 25);
strmid(teamtag, playername, 0, 4);
if(!strcmp(teamtag, "[PG]")) return true;
return false;
}
public OnPlayerConnect(playerid)
{
if(IsPlayerNameHasPGInside(playerid)) KickWithMessage(playerid, -1, "You use the [PG] team tag which isn't allowed !");
return 1;
}