Getting model id of spawned object
#4

pawn Код:
new Obj;
new ObjInGame[MAX_OBJECTS_IN_GAME][2];

dcmd_object(playerid,params[])
{
    new object;
    if(Player[playerid][admin] < 4) SendClientMessage (playerid,COLOR_RED,"Command unavailable");
    else if(sscanf(params,"d",object)) SendClientMessage (playerid,GELTONA,"Usage: /object [object model id]");
    else{
        new Float:bx, Float:by, Float:bz, Float:ba;
        GetPlayerPos(playerid, bx, by, bz);
        GetPlayerFacingAngle(playerid, ba);
        bx += (floatsin(-ba, degrees));
        by += (floatcos(-ba, degrees));
        ObjInGame[Obj][0] = object;
        ObjInGame[Obj][1] = CreateObject(object, bx, by, bz-0.5, 0, 0, ba);
        Obj++;
        ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
    }
    return 1;
}

dcmd_saveobjects(playerid,params[])
{
    if(Player[playerid][admin] < 4) SendClientMessage(playerid,COLOR_RED,"Command unavailable");
    else{
        new File:obj = fopen("objects.txt", io_append);
        new Float:O[6],string[256];
        for(new i = 0; i < Obj; i++)                     //checking all objects
        {
            GetObjectPos(ObjInGame[i][1],O[0],O[1],O[2]);
            GetObjectRot(ObjInGame[i][1],O[3],O[4],O[5]);
            format(string,sizeof(string), "ID: %d - CreateObject(%d,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f);\r\n",ObjInGame[i][1],ObjInGame[i][0],O[0],O[1],O[2],O[3],O[4],O[5]);
            fwrite(obj, string);
        }
        Obj = 0;
        fwrite(obj,"/////////////////////////////////////////END///////////////////////////////////\r\n");
        fclose(obj);
    }
    return 1;
}

RemoveObjectFromFile(objectid)
{
    new File:F[2],str[128],objid[15],len;
    F[0] = fopen("objects.txt",io_read);
    if(!F[0]) return;
    F[1] = fopen("temporary_objects_file.txt",io_write);

    format(objid,sizeof(objid),"ID: %d -",objectid);
    len = strlen(objid);

    while(fread(F[0],str))
    {
        if(!strcmp(str,objid,true,len)) continue;
        fwrite(F[1],str);
    }

    fclose(F[0]);
    fclose(F[1]);

    F[0] = fopen("temporary_objects_file.txt",io_read);
    F[1] = fopen("objects.txt",io_write);

    while(fread(F[0],str))
        fwrite(F[1],str);

    fclose(F[0]);
    fclose(F[1]);
    fremove("temporary_objects_file.txt");
}

public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
{
    if(type == SELECT_OBJECT_GLOBAL_OBJECT)
    {
        DestroyObject(objectid);
        RemoveObjectFromFile(objectid);
    }
    else
    {
        DestroyPlayerObject(playerid, objectid);
    }
    SendClientMessage(playerid, 0xFFFFFFFF, "You have deleted selected object!");
    return 1;
}
Reply


Messages In This Thread
Getting model id of spawned object - by dNsLTU - 10.08.2012, 21:46
Re: Getting model id of spawned object - by Jefff - 10.08.2012, 23:13
Re: Getting model id of spawned object - by dNsLTU - 11.08.2012, 11:05
Re: Getting model id of spawned object - by Jefff - 11.08.2012, 14:12
Re: Getting model id of spawned object - by dNsLTU - 11.08.2012, 17:41
Re: Getting model id of spawned object - by Jefff - 11.08.2012, 20:49
Re: Getting model id of spawned object - by dNsLTU - 12.08.2012, 15:00
Re: Getting model id of spawned object - by dNsLTU - 13.08.2012, 10:42

Forum Jump:


Users browsing this thread: 1 Guest(s)