20.01.2012, 05:03
why my OnPlayerCommandText is bug if im in game i type /sb or /seatbelt wont work its said "Unknown Command" help me please ASAP!!
here the code
here the code
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new cmd[256];
new tmp[256];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid, idx;
cmd = strtok(cmdtext, idx);
new sendername[MAX_PLAYER_NAME];
if(strcmp(cmd,"/sb",true)==0)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
SendClientMessage(playerid,COLOR_GREY,"You need to be in a vehicle.");
return 1;
}
if(PlayerInfo[playerid][pSeatBelt] == 1)
{
PlayerInfo[playerid][pSeatBelt] = 0;
GetPlayerName(playerid, sendername, sizeof(sendername));
new stringtosee[255];
format(stringtosee, sizeof(stringtosee), "*** %s unbuckles his/her seatbelt.", sendername);
ProxDetector(30.0, playerid, stringtosee, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
return 1;
}
PlayerInfo[playerid][pSeatBelt] = 1;
GetPlayerName(playerid, sendername, sizeof(sendername));
new stringtosee[255];
format(stringtosee, sizeof(stringtosee), "*** %s buckles his/her seatbelt.", sendername);
ProxDetector(30.0, playerid, stringtosee, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
}
//Checking seatbelt
if(strcmp(cmd, "/checksb", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /checksb [playerid]");
return 1;
}
new playa;
if(strlen(tmp))
{
playa = ReturnUser(tmp);
}
else
{
playa = strval(tmp);
}
if(GetPlayerState(playa) == PLAYER_STATE_ONFOOT)
{
SendClientMessage(playerid,COLOR_GREY,"Player isn't in a vehicle.");
return 1;
}
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
if(IsAPoliceSkin(playerid))
{
giveplayerid = ReturnUser(tmp);
if(ProxDetectorS(9.0, playerid, giveplayerid))
{
new stext[255];
if(PlayerInfo[playa][pSeatBelt] == 0)
{
stext = "off";
}
else if(PlayerInfo[playa][pSeatBelt] == 1)
{
stext = "on";
}
format(string, sizeof(string), "%s have the seatbelt %s." , giveplayer , stext);
SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 30.0, 6000);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "That player is not near you!");
}
}
else
{
SendClientMessage(playerid,COLOR_GREY,"You're not an Police Officer!");
}
return 1;
}
return 0;
}
public IsAPoliceSkin(skinid)
{
if((skinid >= 265 && skinid <= 266) || (skinid == 267) || (skinid == 280) || (skinid == 281) || (skinid == 282) || (skinid == 283) || (skinid == 284) || (skinid == 285) || (skinid == 286) || (skinid == 287) || (skinid == 288))
{
return 1;
}
return 0;
}