Destroying a dynamic object.
#1

Hello there, when am destroying the ATM and restarting the server, the object won't be deleted why? I guess it won't save so that's why it won't be deleted. How can i fix that.

PHP код:
    }
    if(
dialogid == 52)
    {
        if(
response)
        {
            new 
tmpid IsPlayerAtATM(playerid);
            if(
tmpid!=-1)
            {
                new 
path[32];
                
format(path,sizeof(path),"atm%d.txt",tmpid);
                
dini_Remove(path);
                
Delete3DTextLabel(atmInfo[tmpid][aText]);
                
DestroyDynamicObject(atmInfo[tmpid][aObject]);
                
atmInfo[tmpid][aX]=0.0;
                
atmInfo[tmpid][aY]=0.0;
                
atmInfo[tmpid][aZ]=0.0;
                
atmInfo[tmpid][aA]=0.0;
                
//SendClientMessage(playerid, COLOR_GREY,"ATM ID: %d destroyed successfully",tmpid);
                
new string[128];
                
format(stringsizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has destroyed an ATM"RPN(playerid));
                
SendAdminMessage(COLOR_DARKRED1string);
                return 
1;
            } else return 
0;
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GREY,"Destroying ATM canceled");
            return 
1;
        }
    }
    if(
dialogid == 51)
    {
        if(
response)
        {
            new 
Float:Pos[4];
            
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
            
GetPlayerFacingAngle(playerid,Pos[3]);
            
//new atmid = CreateATM(Pos[0],Pos[1],Pos[2],Pos[3]);
            
CreateATM(Pos[0],Pos[1],Pos[2],Pos[3]);
            
//SendClientMessage(playerid, COLOR_GREY,"ATM ID: %d successfully created", atmid);
            
new string[128];
               
format(stringsizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created an ATM"RPN(playerid));
            
SendAdminMessage(COLOR_DARKRED1string);
            return 
1;
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GREY,"Creating ATM canceled");
            return 
1;
        } 
The command:

PHP код:
}
CMD:deleteatm(playeridparams[])
{
        if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
        if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
        {
        new 
tmpid IsPlayerAtATM(playerid);
        if(
tmpid!=-1)
        {
            new 
stringa[MAX_STRING];
            
format(stringa,sizeof(stringa),"Are you sure you want to destroy ATM ID: %d",tmpid);
            
ShowPlayerDialog(playerid,52,DIALOG_STYLE_MSGBOX,"ATM destroy",stringa,"Yes","No");
            return 
1;
        } else return 
SendClientMessage(playeridCOLOR_GREY,"You are not at ATM");
    }

Reply
#2

Is there any way to fix this? Sorry for double post.
Reply
#3

Does the IsPlayerAtATM-function actually return the Atm's ID or just 0 (if not) or 1 (if player is at atm)?
Reply
#4

Atm's ID
Reply
#5

Does the file get deleted when you destroy the Atm?
Reply
#6

Quote:
Originally Posted by Schneider
Посмотреть сообщение
Does the file get deleted when you destroy the Atm?
Nope.
Reply
#7

Try to add some debug-prints between each line, reload the server, try to delete an ATM as usual then open your serverlog.txt and see what gets printed and what not:

pawn Код:
if(dialogid == 52)
{
    print("Dialog 52 called");
    if(response)
    {
        print("Respones = 1");
        new tmpid = IsPlayerAtATM(playerid);
        printf("Current ATM ID: %d", tmpid);
        if(tmpid!=-1)
        {
            print("ID is NOT -1)"
            new path[32];
            format(path,sizeof(path),"atm%d.txt",tmpid);
            printf("Trying to delete file: %s", path");
            dini_Remove(path);
            print("
File removed");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)