Proplem with player pos
#1

i want my player should spawn after death at the position where he typed the command and joined the Dm.

i tried this script but it didn't work, player is spawning some where in the air.

pawn Код:
new InDM[MAX_PLAYERS];
new Dead[MAX_PLAYERS];
new DmID[MAX_PLAYERS];

new Float:dmx, Float:dmy, Float:dmz;

CMD:mgdm(playerid, params[])
{
    InDM[playerid] = 1;
    DmID[playerid] = 1;
    InLobby[playerid] = 0;

    GetPlayerPos(playerid, dmx, dmy, dmz);
   
    SendClientMessage(playerid, -1, "{FFFF00}Welcome to Minigun DM !");
    SetPlayerInterior(playerid, 14);
    new rand = random(sizeof(RandomSpawnMGDM));
    SetPlayerPos(playerid, RandomSpawnMGDM[rand][0], RandomSpawnMGDM[rand][1], RandomSpawnMGDM[rand][2]);
    SetPlayerVirtualWorld(playerid, 32);

    ResetPlayerWeapons(playerid);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100);
    GivePlayerWeapon(playerid, 38, 100000);

    new str[56+MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), "{9933FF}***%s (ID: %d) has joined Minigun DM. (/mgdm)!", name, playerid);
    SendClientMessageToAll(-1, str);
        return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
       
    SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
   
   
    if(InDM[playerid] == 1)
    {
       if(killerid != INVALID_PLAYER_ID)
       {
       GivePlayerMoney(killerid, 5000);
       SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
       SendClientMessage(killerid, -1, "You have been awarded $5000 & +1 Score for killing your opponent in DM.");
       InDM[playerid] = 1;
       InLobby[playerid] = 1;
       Dead[playerid] = 1;
       return 1;
       }
    }
public OnPlayerSpawn(playerid)
{
    if(Dead[playerid] == 1 && InDM[playerid] == 1)
    {
    SetPlayerPos(playerid, dmx, dmy, dmz);
        Dead[playerid] = 0;
        DmID[playerid] = 0;
        InDM[playerid] = 0;
     }
return 1;
}
where is the mistake?
the player is spawning some where in sky.

thanks in advance
Reply
#2

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Set the interior to 14 when the player spawn again.
Use the floats with player arrays, or itll go bugged.

new Float:dmx, Float:dmy, Float:dmz;

to

new Float:dmx[MAX_PLAYERS], Float:dmy[MAX_PLAYERS], Float:dmz[MAX_PLAYERS];
i dont want player should be spawned in interior
i want to make that when he dies he should get back to normal world where he typed the command
Reply
#3

make a change in ralie script above
pawn Код:
new oldDMposX[MAX_PLAYERS],
    oldDMposY[MAX_PLAYERS],
    oldDMposZ[MAX_PLAYERS];
cahnge this to this
pawn Код:
new Float:oldDMposX[MAX_PLAYERS],
   Float:oldDMposY[MAX_PLAYERS],
    Float:oldDMposZ[MAX_PLAYERS];
Reply
#4

Just check whether this works
pawn Код:
new InDM[MAX_PLAYERS];
new Dead[MAX_PLAYERS];
new DmID[MAX_PLAYERS];

new Float:dmx[MAX_PLAYERS], Float:dmy[MAX_PLAYERS], Float:dmz[MAX_PLAYERS];

CMD:mgdm(playerid, params[])
{
    InDM[playerid] = 1;
    DmID[playerid] = 1;
    InLobby[playerid] = 0;

    GetPlayerPos(playerid, dmx[playerid], dmy[playerid], dmz[playerid]);
    SetTimerEx("DMTimer",100,true,"u",playerid);
    return 1;
}

forward DMTimer(playerid);
public DMTimer(playerid)
{
    SendClientMessage(playerid, -1, "{FFFF00}Welcome to Minigun DM !");
    SetPlayerInterior(playerid, 14);
    new rand = random(sizeof(RandomSpawnMGDM));
    SetPlayerPos(playerid, RandomSpawnMGDM[rand][0], RandomSpawnMGDM[rand][1], RandomSpawnMGDM[rand][2]);
    SetPlayerVirtualWorld(playerid, 32);

    ResetPlayerWeapons(playerid);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100);
    GivePlayerWeapon(playerid, 38, 100000);

    new str[56+MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), "{9933FF}***%s (ID: %d) has joined Minigun DM. (/mgdm)!", name, playerid);
    SendClientMessageToAll(-1, str);
}


public OnPlayerDeath(playerid, killerid, reason)
{

    SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed


    if(InDM[playerid] == 1)
    {
       if(killerid != INVALID_PLAYER_ID)
       {
       GivePlayerMoney(killerid, 5000);
       SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
       SendClientMessage(killerid, -1, "You have been awarded $5000 & +1 Score for killing your opponent in DM.");
       InDM[playerid] = 1;
       InLobby[playerid] = 1;
       Dead[playerid] = 1;
       return 1;
       }
    }
}
public OnPlayerSpawn(playerid)
{
    if(Dead[playerid] == 1 && InDM[playerid] == 1)
    {
        SetPlayerPos(playerid, dmx[playerid], dmy[playerid], dmz[playerid]);
        Dead[playerid] = 0;
        DmID[playerid] = 0;
        InDM[playerid] = 0;
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Exactly! Im sorry ive missed that.
but your code still gets the pos after player joining the Dm....so he is spawning in the air after he gets died
Reply
#6

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
No, try it.
it is always taking me to each in whetstone...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)