Help with GetPlayerWeaponData
#1

Hello, i made a enum to save the players weapons for the next time they join, and i used this:

pawn Код:
new rweaponid, rammo;
new sweaponid2, sammo2;
new zweaponid3, zammo3;

enum pInfo
{
pWeapon1,
    pWeapon2,
    pWeapon3,
    pAmmo1,
    pAmmo2,
    pAmmo3,
    pModel,
    pSkin,
    Float: pPos_x,
    Float: pPos_y,
    Float: pPos_z,
    Float: pPos_r,
    pInt,
};

public OnPlayerSpawn(playerid)
{
switch(gClass[playerid])
    {
        case 0:
        {
            SetPlayerColor(playerid, 0x004080FF);
            new Float:x,Float:y,Float:z;
            GetPlayerPos(playerid, x, y, z);
            new Float:angle;
            GetPlayerFacingAngle(playerid, angle);
            new skin = GetPlayerSkin(playerid);
            new Int = GetPlayerInterior(playerid);
            GetPlayerWeaponData(playerid, 1, rweaponid, rammo);
            PlayerInfo[playerid][pWeapon1] = rweaponid;
            PlayerInfo[playerid][pAmmo1] = rammo;
            GetPlayerWeaponData(playerid, 2, sweaponid2, sammo2);
            PlayerInfo[playerid][pWeapon2] = sweaponid2;
            PlayerInfo[playerid][pAmmo2] = sammo2;
            GetPlayerWeaponData(playerid, 3, zweaponid3, zammo3);
            PlayerInfo[playerid][pWeapon3] = zweaponid3;
            PlayerInfo[playerid][pAmmo3] = zammo3;
            PlayerInfo[playerid][pSkin] = skin;
            PlayerInfo[playerid][pModel] = 0;
            PlayerInfo[playerid][pPos_x] = x;
            PlayerInfo[playerid][pPos_y] = y;
            PlayerInfo[playerid][pPos_z] = z;
            PlayerInfo[playerid][pPos_r] = angle;
            PlayerInfo[playerid][pInt] = Int;
            return 1;
        }
         }
         return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
new team = PlayerInfo[playerid][pModel];
    new Float: Xpos = PlayerInfo[playerid][pPos_x];
    new Float: Ypos = PlayerInfo[playerid][pPos_y];
    new Float: Zpos = PlayerInfo[playerid][pPos_z];
    new Float: Rpos = PlayerInfo[playerid][pPos_r];
    new skin = PlayerInfo[playerid][pSkin];
    new wep1 = PlayerInfo[playerid][pWeapon1];
    new wep2 = PlayerInfo[playerid][pWeapon2];
    new wep3 = PlayerInfo[playerid][pWeapon3];
    new ammo1 = PlayerInfo[playerid][pAmmo1];
    new ammo2 = PlayerInfo[playerid][pAmmo2];
    new ammo3 = PlayerInfo[playerid][pAmmo3];
    new Int = PlayerInfo[playerid][pInt];

if (strcmp(cmd, "/login", true) ==0 )
    {
        if(IsPlayerConnected(playerid))
        {
            new tmppass[64];
            if(gPlayerLogged[playerid] == 1)
            {
                SendClientMessage(playerid, grey, " You are already logged in.");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, grey, " USAGE: /login [password]");
                return 1;
            }
            strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
            String(tmppass);
            OnPlayerLogin(playerid,tmppass);
            SetSpawnInfo(playerid, team, skin, Xpos, Ypos, Zpos, Rpos, wep1, ammo1, wep2, ammo2, wep3, ammo3);
            SetPlayerInterior(playerid, Int);
            SpawnPlayer(playerid);
        }
        return 1;
    }
        return 0;
}
But it seems to dont work, because the positions, skins, and teams work, but you spawn without guns, whats the problem with the code? Thanks you and happy chrismas
Reply
#2

Код:
            GivePlayerWeapon(playerid,wep1,ammo1);
            GivePlayerWeapon(playerid,wep2,ammo2);
            GivePlayerWeapon(playerid,wep3,ammo3);
Use this when you login!
Reply
#3

Quote:
Originally Posted by akis_tze
Посмотреть сообщение
Код:
            GivePlayerWeapon(playerid,wep1,ammo1);
            GivePlayerWeapon(playerid,wep2,ammo2);
            GivePlayerWeapon(playerid,wep3,ammo3);
Use this when you login!
But at SetSpawnInfo when it says wep1, ammo1 i should put 0?
Reply
#4

I don't understand it :/
Reply
#5

Quote:
Originally Posted by akis_tze
Посмотреть сообщение
I don't understand it :/
at
pawn Код:
SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
you can set the position, team, skin, weapons and ammo of a player, thats why i used it but it seems to dont give the weapons to the players
Reply
#6

Does this works??

Код:
if (strcmp(cmd, "/login", true) ==0 )
    {
        if(IsPlayerConnected(playerid))
        {
            new tmppass[64];
            if(gPlayerLogged[playerid] == 1)
            {
                SendClientMessage(playerid, grey, " You are already logged in.");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, grey, " USAGE: /login [password]");
                return 1;
            }
            strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
            String(tmppass);
            OnPlayerLogin(playerid,tmppass);
            SetSpawnInfo(playerid, team, skin, Xpos, Ypos, Zpos, Rpos);
            SetPlayerInterior(playerid, Int);
            GivePlayerWeapon(playerid,wep1,ammo1);
            GivePlayerWeapon(playerid,wep2,ammo2);
            GivePlayerWeapon(playerid,wep3,ammo3);
            SpawnPlayer(playerid);
        }
        return 1;
    }
        return 0;
}
Try this and tell me if that works...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)