What's wrong with this ?
#1

Hey , i maked /vbox command using dudb :
pawn Код:
dcmd_vbox(playerid, params[])
{
#pragma unused params
    if (Vip[playerid] < 1 ) {
        SendClientMessage(playerid, COLOR_CERVENA, "  [!] Only Vips can do that !");
    }
    else {
        if (Vip[playerid] >= 1) {
        if (vbox[playerid] == 1) {
    SendClientMessage(playerid, COLOR_CERVENA, " You can not spawn two boxes !");
        }
        if (vbox[playerid] == 0) {
        new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    CreateObject(1685, x, y+2.0, z, 0.0, 0.0,0.0);
    vbox[playerid] = 1;
    }
    }
    }
    return 1;
}
and a command to remove it :
pawn Код:
dcmd_vrbox(playerid, params[])
{
#pragma unused params
    if (Vip[playerid] < 1 ) {
        SendClientMessage(playerid, COLOR_CERVENA, "  [!] Only Vips can do that !");
    }
    else {
        if (Vip[playerid] >= 1) {
        if (vbox[playerid] == 0) {
    SendClientMessage(playerid, COLOR_CERVENA, "You must spawn a box first to remove it !");
        }
        if (vbox[playerid] == 1) {
        new Float:x, Float:y, Float:z;
    GetPlayerObjectPos(playerid, 1685, Float:x, Float:y, Float:z);
    DestroyObject(1685);
    vbox[playerid] = 0;
    }
    }
    }
    return 1;
}
the problem is with /vrbox command , whene i type it it doesn't remove the box....
i hope you help me to fix this problem , Thanks.
Reply
#2

pawn Код:
new BoxObj[MAX_PLAYERS];
pawn Код:
BoxObj[playerid] = CreateObject(1685, x, y+2.0, z, 0.0, 0.0,0.0);
pawn Код:
DestroyObject(BoxObj[playerid]);
Reply
#3

so i change this :
pawn Код:
DestroyObject(1685);
to this :
pawn Код:
DestroyObject(vbox[playerid]);
?
Reply
#4

Quote:
Originally Posted by ServerScripter
Посмотреть сообщение
so i change this :
pawn Код:
DestroyObject(1685);
to this :
pawn Код:
DestroyObject(vbox[playerid]);
?
yes because with this you destroy the specific object..if you code..destoryobject(1685); it will destroy generally id 1685 object.
Reply
#5

No, you do the same I did... if you destroy vbox variable, that will whether 1 or 0, because it's a variable that checks whether a person has created box or not. Do the same thing I did.
Reply
#6

@vassilis Thanks !
but i have a problem , whene i do /vbox the first time then /vrbox , it doesn't delete the Box , and whene i do again /vbox (so i have 2 boxes) then /vrbox , it removes it , so the script can't delete the first box , how to fix it ? thanks.
@Toreno ok i will test that now..
Edit:
The same thing with your code Toreno
Reply
#7

pawn Код:
new BoxObj[MAX_PLAYERS];

dcmd_vbox(playerid, params[])
{
    #pragma unused params
    if (Vip[playerid] < 1 ) {
        SendClientMessage(playerid, COLOR_CERVENA, "  [!] Only Vips can do that !");
    }
    else {
        if (Vip[playerid] >= 1) {
            if (vbox[playerid] == 1) {
                SendClientMessage(playerid, COLOR_CERVENA, " You can not spawn two boxes !");
            }
            if (vbox[playerid] == 0) {
                new Float:x, Float:y, Float:z;
                GetPlayerPos(playerid, x, y, z);
                DestroyObject(BoxObj[playerid]);
                BoxObj[playerid] = CreateObject(1685, x, y+2.0, z, 0.0, 0.0,0.0);
                vbox[playerid] = 1;
            }
        }
    }
    return 1;
}
dcmd_vrbox(playerid, params[])
{
    #pragma unused params
    if (Vip[playerid] < 1 ) {
        SendClientMessage(playerid, COLOR_CERVENA, "  [!] Only Vips can do that !");
    }
    else {
        if (Vip[playerid] >= 1) {
            if (vbox[playerid] == 0) {
                SendClientMessage(playerid, COLOR_CERVENA, "You must spawn a box first to remove it !");
            }
            if (vbox[playerid] == 1) {
                new Float:x, Float:y, Float:z;
                GetPlayerObjectPos(playerid, 1685, Float:x, Float:y, Float:z);
                DestroyObject(BoxObj[playerid]);
                vbox[playerid] = 0;
            }
        }
    }
    return 1;
}
Reply
#8

That should work perfectly, do exactly the same, don't change a thing.
pawn Код:
new
    BoxObject[ MAX_PLAYERS ],
    BoxVariable[ MAX_PLAYERS ]
;

dcmd_vbox( playerid, params[] )
{
    #pragma unused params

    if( Vip[ playerid ] < 1 )
        return SendClientMessage( playerid, COLOR_CERVENA, "  [!] Only Vips can do that !" );

    if( BoxVariable[ playerid ] )
        return SendClientMessage( playerid, COLOR_CERVENA, " You can not spawn two boxes !" );
       
    new
        Float:x,
        Float:y,
        Float:z
    ;
   
    GetPlayerPos( playerid, x, y, z );
    BoxObject[ playerid ] = CreateObject( 1685, x, y+2.0, z, 0.0, 0.0, 0.0 );
   
    BoxVariable[playerid] = 1;
   
    return 1;
}

dcmd_vrbox( playerid, params[] )
{
    #pragma unused params
   
    if( Vip[ playerid ] < 1 )
        return SendClientMessage( playerid, COLOR_CERVENA, "  [!] Only Vips can do that !" );
       
    if( !BoxVariable[ playerid ] )
        return SendClientMessage( playerid, COLOR_CERVENA, "You must spawn a box first to remove it !" );
       
    DestroyObject(BoxObject[ playerid ]);

    BoxVariable[playerid] = 0;

    return 1;
}
Reply
#9

thank u but 1 question : i already have new vbox so i need to add also new BoxObj ?
Reply
#10

Quote:
Originally Posted by ServerScripter
Посмотреть сообщение
thank u but 1 question : i already have new vbox so i need to add also new BoxObj ?
Quote:
Originally Posted by Toreno
Посмотреть сообщение
That should work perfectly, do exactly the same, don't change a thing.
pawn Код:
new
    BoxObject[ MAX_PLAYERS ],
    BoxVariable[ MAX_PLAYERS ]
;

dcmd_vbox( playerid, params[] )
{
    #pragma unused params

    if( Vip[ playerid ] < 1 )
        return SendClientMessage( playerid, COLOR_CERVENA, "  [!] Only Vips can do that !" );

    if( BoxVariable[ playerid ] )
        return SendClientMessage( playerid, COLOR_CERVENA, " You can not spawn two boxes !" );
       
    new
        Float:x,
        Float:y,
        Float:z
    ;
   
    GetPlayerPos( playerid, x, y, z );
    BoxObject[ playerid ] = CreateObject( 1685, x, y+2.0, z, 0.0, 0.0, 0.0 );
   
    BoxVariable[playerid] = 1;
   
    return 1;
}

dcmd_vrbox( playerid, params[] )
{
    #pragma unused params
   
    if( Vip[ playerid ] < 1 )
        return SendClientMessage( playerid, COLOR_CERVENA, "  [!] Only Vips can do that !" );
       
    if( !BoxVariable[ playerid ] )
        return SendClientMessage( playerid, COLOR_CERVENA, "You must spawn a box first to remove it !" );
       
    DestroyObject(BoxObject[ playerid ]);

    BoxVariable[playerid] = 0;

    return 1;
}
DO THIS.

The two variables are supposed to be at top of your script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)