#1

pawn Код:
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;
    }
How can I do so the player needs to be in /afk to use the /back cmd?
Reply
#2

Try this

pawn Код:
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;
}
Reply
#3

Okay, another question. What is wrong with this code?
Each time I die it says "You may not drive-by with this weapon."

pawn Код:
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;
}
Reply
#4

Quote:
Originally Posted by HighPitchedVoice
Посмотреть сообщение
Okay, another question. What is wrong with this code?
Each time I die it says "You may not drive-by with this weapon."

pawn Код:
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;
}
Replace '&' with '=='

pawn Код:
if(newstate == PLAYER_STATE_PASSENGER)
Reply
#5

Okay, how can I add cars to my script? :P
Reply
#6

Quote:
Originally Posted by HighPitchedVoice
Посмотреть сообщение
Okay, how can I add cars to my script? :P
Use sa-mp debug
Reply
#7

Is there any "IsPlayerCloseToEnemy" function? :S
Reply
#8

Quote:
Originally Posted by HighPitchedVoice
Посмотреть сообщение
Is there any "IsPlayerCloseToEnemy" function? :S
I have seen this on another server so that's why I ask.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)