if (strcmp("/afk", cmdtext, true, 10) ==0)
{
new pName[MAX_PLAYER_NAME],str[100];
GetPlayerName(playerid,pName,sizeof(pName));
format(str,sizeof(str),"{8E2323} %s went to the AFK room (/afk).",pName);
SetPlayerPos(playerid, 1798.2366,-1303.9529,120.2656);
SendClientMessageToAll(-1,str);
ResetPlayerWeapons(playerid);
return 1;
}
if (strcmp("/back", cmdtext, true, 10) == 0)
{
new pName[MAX_PLAYER_NAME],str[100];
GetPlayerName(playerid,pName,sizeof(pName));
format(str,sizeof(str),"{8E2323} %s exited the AFK room (/back).",pName);
SpawnPlayer(playerid);
SendClientMessageToAll(-1,str);
return 1;
}
new PlayerAFK[MAX_PLAYERS]; //at the top of your script
//Under onplayercommandtext
if (strcmp("/afk", cmdtext, true, 10) ==0)
{
new pName[MAX_PLAYER_NAME],str[100];
GetPlayerName(playerid,pName,sizeof(pName));
if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid,-1,"You already afk.");
PlayerAFK[playerid] = 1;
SetPlayerPos(playerid, 1798.2366,-1303.9529,120.2656);
ResetPlayerWeapons(playerid);
format(str,sizeof(str),"{8E2323} %s went to the AFK room (/afk).",name);
SendClientMessageToAll(-1,str);
return 1;
}
if (strcmp("/back", cmdtext, true, 10) ==0)
{
new pName[MAX_PLAYER_NAME],str[100];
GetPlayerName(playerid,pName,sizeof(pName));
format(str,sizeof(str),"{8E2323} %s exited the AFK room (/back).",name);
if(PlayerAFK[playerid] == 0) return SendClientMessage(playerid,-1,"You are not AFK");
PlayerAFK[playerid] = 0;
SpawnPlayer(playerid);
SendClientMessageToAll(-1,str);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate) {
if(newstate & PLAYER_STATE_PASSENGER) {
if(GetPlayerWeapon(playerid) == 24) {
SetPlayerArmedWeapon(playerid, 0);
SendClientMessage(playerid, COLOR_ORANGE, "You may not drive-by with this weapon.");
}
else if(newstate & PLAYER_STATE_PASSENGER) {
if(GetPlayerWeapon(playerid) == 27) {
SetPlayerArmedWeapon(playerid, 0);
SendClientMessage(playerid, COLOR_ORANGE, "You may not drive-by with this weapon.");
}
}
}
return true;
}
Okay, another question. What is wrong with this code?
Each time I die it says "You may not drive-by with this weapon." pawn Код:
|
if(newstate == PLAYER_STATE_PASSENGER)