SA-MP Forums Archive
I don't know what is wrong. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: I don't know what is wrong. (/showthread.php?tid=158033)



I don't know what is wrong. - Aleksandar_Zivanovci - 08.07.2010

Hi all,

well there is a problem, when some one die he/she will be respawned at hospital, but user with id 0 will be spawned with that other user too, does any one know why is that happening


Re: I don't know what is wrong. - Hiddos - 08.07.2010

Show me your code that does this. Any SpawnPlayer functions you using?


Re: I don't know what is wrong. - Aleksandar_Zivanovci - 08.07.2010

This is when player die.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason) {
    new pname[256], deathquery[512], deathrow[512], deathfield[10][25], cash;
    GetPlayerName(playerid, pname, sizeof (pname));
    SendClientMessage(playerid, COLOR_LIGHTRED, "You almost died. \nSan Andreas Paramedic has heald you. \nPay: 300$");
    format(deathquery, sizeof (deathquery), "SELECT * FROM players WHERE name = '%s'", pname);
    mysql_query(deathquery);
    mysql_store_result();
    mysql_fetch_row(deathrow);
    split(deathrow, deathfield, '|');
    cash = PlayerInfo[playerid][Cash] - 300;
    format(deathquery, sizeof (deathquery), "UPDATE players SET cash = %d WHERE name = '%s' ", cash, pname);
    mysql_query(deathquery);
    PlayerInfo[playerid][Cash] = cash;
    OnPlayerDied(playerid);
    return 0;
}
after that it call function OnPlayerDied()

pawn Код:
public OnPlayerDied(playerid) {
    SetPlayerCameraPos(playerid, 1242.607421, 327.397186, 19.755510);
    SetPlayerCameraLookAt(playerid, 1242.607421, 327.397186, 19.755510);
    if (IsPlayerConnected(playerid)) {
        SetPlayerHealth(playerid, 50.0);
        if (GetPlayerWeapon(playerid) >= 0) {
            ResetPlayerWeapons(playerid);
        }
        IsDeath[playerid] = 1;
        SetTimer("spawn", 5000, false);
    }
}
this function call function spawn which spawn player and set IsDeath[playerid] to 1
after that goes this

pawn Код:
public OnPlayerDisconnect(playerid, reason) {
    IsPlayerAfk[playerid] = 0;
    IsLogged[playerid] = 0;
    IsDeath[playerid] = 0;
    showspeedo[playerid] = 0;
    gVirtualWorld[playerid] = 0;
    PlayerFrozen[playerid] = 0;
    IsPlayerAfk[playerid] = 0;
    PlayerHealth[playerid] = 100;
    PlayerArmour[playerid] = 0;
    PlayerInfo[playerid][Cash] = 0;
    gLastX[playerid] = 0;
    gLastY[playerid] = 0;
    gLastZ[playerid] = 0;
}

public OnPlayerSpawn(playerid) {
    new name[256], queryspawn[512], rowspawn[512], fieldspawn[11][20];
    new Float:spawnx, Float:spawny, Float:spawnz;
    new hsfield[3][10];
    GetPlayerName(playerid, name, sizeof (name));
    if (IsLogged[playerid] == 0) {
        SendClientMessage(playerid, COLOR_GRAD2, "SERVER: You have not logged in yet.");
        return 1;
    }
    PlayerPlaySound(playerid, 1186, 0, 0, 0);
    format(queryspawn, sizeof (queryspawn), "SELECT * FROM players WHERE name = '%s'", name);
    mysql_query(queryspawn);
    mysql_store_result();
    if (mysql_num_rows() != 0) {
        mysql_fetch_row(rowspawn);
        split(rowspawn, fieldspawn, '|');
        new FactionID[MAX_PLAYERS];
        FactionID[playerid] = strval(fieldspawn[7]);
        pSkinID[playerid] = strval(fieldspawn[4]);
        if (PlayerInfo[playerid][Faction] != 0) {
            new skinq[512], skinrow[512], skinf[3][20];
            format(skinq, sizeof (skinq), "SELECT * FROM faction_skins WHERE faction = %d AND rank = %d", strval(fieldspawn[7]), strval(fieldspawn[9]));
            mysql_query(skinq);
            mysql_store_result();
            mysql_fetch_row(skinrow);
            split(skinrow, skinf, '|');
            SetPlayerSkin(playerid, strval(skinf[0]));
            pSkinID[playerid] = strval(skinf[0]);
        }
        new spawnq[512], spawnr[512], spawnfield[3][50];
        format(spawnq, sizeof (spawnq), "SELECT * FROM spawn WHERE PlayerName = '%s'", name);
        mysql_query(spawnq);
        mysql_store_result();
        mysql_fetch_row(spawnr);
        split(spawnr, spawnfield, '|');
        if (strval(spawnfield[1]) == 1) {
            spawnx = 1242.607421;
            spawny = 327.397186;
            spawnz = 19.755510;
        } else if (strval(spawnfield[1]) == 2) {
            format(spawnq, sizeof (spawnq), "SELECT  `px` ,  `py` ,  `pz` FROM  `houses` WHERE owner = '%s'", name);
            mysql_query(spawnq);
            mysql_store_result();
            mysql_fetch_row(spawnr);
            split(spawnr, hsfield, '|');
            spawnx = floatstr(hsfield[0]);
            spawny = floatstr(hsfield[1]);
            spawnz = floatstr(hsfield[2]);
        } else if (strval(spawnfield[1]) == 3) {
            format(spawnq, sizeof (spawnq), "SELECT  `px` ,  `py` ,  `pz` FROM  `factionhq` WHERE faction_id = %d", FactionID[playerid]);
            mysql_query(spawnq);
            mysql_store_result();
            mysql_fetch_row(spawnr);
            split(spawnr, hsfield, '|');
            spawnx = floatstr(hsfield[0]);
            spawny = floatstr(hsfield[1]);
            spawnz = floatstr(hsfield[2]);
        }
    }
    if (IsDeath[playerid] == 1) {
        spawnx = 1242.607421;
        spawny = 327.397186;
        spawnz = 19.755510;
        ResetPlayerMoney(playerid);
        GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
        SetPlayerSkin(playerid, pSkinID[playerid]);
        SetPlayerPos(playerid, spawnx, spawny, spawnz);
        IsDeath[playerid] = 0;
    } else {
        GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
        SetPlayerSkin(playerid, pSkinID[playerid]);
        SetPlayerPos(playerid, spawnx, spawny, spawnz);
        return 1;
    }
    return 1;
}
so if you could help me i would be happy


Re: I don't know what is wrong. - Hiddos - 08.07.2010

Can you give me your "spawn" function?


Re: I don't know what is wrong. - Aleksandar_Zivanovci - 08.07.2010

its just
pawn Код:
public spawn(playerid){
      SpawnPlayer(playerid);
       retrurn ;1;
}



Re: I don't know what is wrong. - Hiddos - 08.07.2010

Got the problem, "SetTimer" is for calling a callback without parameters, 'spawn' has got a parameter.

Use this:

pawn Код:
SetTimerEx("spawn", 5000, false,"d",playerid);
Replace it with the SetTimer() commmand at "OnPlayerDied" (Death?)


Re: I don't know what is wrong. - Aleksandar_Zivanovci - 08.07.2010

thx man, i replaced it, now i am waiting for friend to come to server


Re: I don't know what is wrong. - Aleksandar_Zivanovci - 08.07.2010

this did not helped it is still happening.