CreatePlayerObject
#1

Hi,
I've got this in my map editor script.

pawn Код:
stock CreateSavingObject(playerid, Model, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Project)
{
    new id, Query[200];

    foreach(new i:Player)
    {
        if(GetPlayerScore(i) == GetPlayerScore(playerid))
        {
            id = CreatePlayerObject(i, Model, X, Y, Z, rX, rY, rZ);
            LastObject[i] = id;
        }
    }
    mysql_format(con, Query,sizeof(Query), "INSERT INTO `PROJECT_%d` (`ID`, `MODEL`) VALUES (%d, %d)", Project, id, Model);
    mysql_tquery(con, Query, "OnObjectCreated", "iiiffffffi", id, Project, Model, X, Y, Z, rX, rY, rZ, playerid);

    return 1;
}
This is called every time an object is created. The script works fine, if there is only one person with the same score (IE it only creates for one person). Otherwise, it sometimes works, and other time doesn't. I haven't been able to determine when it does or doesn't work, seems to be random. However, if it's just one person, there is never an issue. Usually this is resolved by changing your project (which changes your vw and score) and setting it back.

However, i've noticed (again, if there is multiplayer) it creates max objects, which is 999, but doesn't remove null ones. Using the command /purge fixes this.

pawn Код:
stock SetPlayerProject(playerid, projectid)
{
    SetPlayerScore(playerid, projectid);
    SetPlayerVirtualWorld(playerid, projectid);
    for(new i; i<MAX_OBJECTS; i++)
    {
        DestroyPlayerObject(playerid, i);
    }

    for(new i = 1; i<1000; i++)
    {
        CreatePlayerObject(playerid, ObjectInfo[projectid][i][oModel], ObjectInfo[projectid][i][oX], ObjectInfo[projectid][i][oY], ObjectInfo[projectid][i][oZ], ObjectInfo[projectid][i][orX], ObjectInfo[projectid][i][orY], ObjectInfo[projectid][i][orZ]);
        if(ObjectInfo[projectid][i][oMid] !=0)
        {
            SetPlayerObjectMaterial(playerid, i, ObjectInfo[projectid][i][oMindex], ObjectInfo[projectid][i][oMid], ObjectInfo[projectid][i][oMtxd], ObjectInfo[projectid][i][oMtexture], 0);
        }
    }
    cmd_purge(playerid);
    if(projectid != 0)
    {
        SpawnPlayer(playerid);
        return 1;
    }
    return 1;
}

CMD:purge(playerid)
{
    for(new i = 1; i<1000; i++)
    {
        new Float:X, Float:Y, Float:Z;
        GetPlayerObjectPos(playerid, i, X, Y, Z);
        if(X == 0 && Y == 0 && Z == 0)
        {
            DestroyPlayerObject(playerid, i);
        }
    }
    return 1;
}
Any suggestions would be much obliged.
Reply
#2

Any suggestions?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)