Disarm players on login
#1

Hello, when players TP from a DM zone, they loose their weapons, but when they leave the server in DM zone, they spawn next time with them. What is the code to disarm players when they join?
Reply
#2

Wrote a couple of functions for you, the names should be enough to tell you what they do.
pawn Код:
enum WEP_DAT
{
    e_iWeapons[13],
    e_iAmmo[13],
};

new gPlayerWeaponData[MAX_PLAYERS][WEP_DAT];

RemoveWeapons(playerid)
{
    for(new i; i < 13; i++)
        GetPlayerWeaponData(playerid, i, gPlayerWeaponData[playerid][e_iWeapons][i], gPlayerWeaponData[playerid][e_iAmmo][i]);

    ResetPlayerWeapons(playerid);//this function disarms players
}

GiveBackWeapons(playerid)
{
    for(new i; i < 13; i++)
        GivePlayerWeapon(playerid, gPlayerWeaponData[playerid][e_iWeapons][i], gPlayerWeaponData[playerid][e_iAmmo][i]);
}
Reply
#3

Isnt it enough to put under OnPlayerConnect:

ResetPlayerWeapons(playerid)


Something like that. short and simple
Reply
#4

Anyone?
Reply
#5

Do you have some sort of variable set for there gun? like playerGun[playerid].. if so set that to 0 on player connect.
Reply
#6

My onplayerconnect:

pawn Код:
public OnPlayerConnect(playerid)
{
    new string[128];
    format(string, sizeof(string), "~r~Welcome to Xtreme Stunts!~n~~n~Please start with reading the /rules");
    GameTextForPlayer(playerid, string, 10000, 4);
    SetPlayerColor(playerid, PlayerColors[playerid]);
    IsInDM[playerid] = 0;
    AutoRepairUsed[playerid] = 0;
    AutoRepairTrigger[playerid] = 0;
    SendClientMessage(playerid, 0x99FFFFAA, "This server has auto repair/flip");
    SendClientMessage(playerid, 0x99FFFFAA, "Welcome! Hope you enjoy your stay!");
    nojump2[playerid] = 0;
    TextDrawShowForPlayer(playerid, Textdraw1);
   
    ReceiveInfo[playerid] = true;

    if(IsVoteKickStarted == true)
    {
        TextDrawShowForPlayer(playerid, Background); //Prevent bugs in case a player connect while a votekick is started
        TextDrawShowForPlayer(playerid, VoteKickTitle);
        TextDrawShowForPlayer(playerid, VoteKickName);
        TextDrawShowForPlayer(playerid, VoteKickVote);
        TextDrawShowForPlayer(playerid, VoteKickTime);
        return 1;
    }
    return 1;
}
Reply
#7

.....
Reply
#8

Someone?
Reply
#9

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Wrote a couple of functions for you, the names should be enough to tell you what they do.
pawn Код:
enum WEP_DAT
{
    e_iWeapons[13],
    e_iAmmo[13],
};

new gPlayerWeaponData[MAX_PLAYERS][WEP_DAT];

RemoveWeapons(playerid)
{
    for(new i; i < 13; i++)
        GetPlayerWeaponData(playerid, i, gPlayerWeaponData[playerid][e_iWeapons][i], gPlayerWeaponData[playerid][e_iAmmo][i]);

    ResetPlayerWeapons(playerid);//this function disarms players
}

GiveBackWeapons(playerid)
{
    for(new i; i < 13; i++)
        GivePlayerWeapon(playerid, gPlayerWeaponData[playerid][e_iWeapons][i], gPlayerWeaponData[playerid][e_iAmmo][i]);
}
First, add that to your script.
Second, look at your code

pawn Код:
// Deathmatch Command
ResetWeapons( playerid );

// GivePlayerWeapon, blablablabla
pawn Код:
// Leave Deathmatch Command
ResetPlayerWeapons( playerid );
GiveBackWeapons( playerid );
Reply
#10

I did. Gave me some errors. There must be a simplier way
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)