delete pickup and text label
#1

Hey guys.

So I have this command to spawn a text label and a pickup, now I wanna know how to make a command to delete it. Help will get +rep, thanks.

pawn Код:
CMD:spawnreqhouse(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
       new Float:x,Float:y,Float:z;
       GetPlayerPos(playerid,x,y,z);
       CreatePickup(1239, 23, x,y,z);
       CreateDynamic3DTextLabel("To request a house at \nthis location, use /requesthouse",COLOR_RED,x,y,z+0.5,4.0);
       return 1;
    }
    return 1;
}
Reply
#2

bump
Reply
#3

new Text3D:houselabel[MAX_PLAYERS];

PHP код:
CMD:spawnreqhouse(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1)
     {
        new 
Float:x,Float:y,Float:z;
       
GetPlayerPos(playerid,x,y,z);
       
CreatePickup(123923x,y,z);
       
label[playerid] = CreateDynamic3DTextLabel("To request a house at \nthis location, use /requesthouse",COLOR_RED,x,y,z+0.5,4.0);
       return 
1;
    }
    return 
1;

PHP код:
CMD:deletehouse(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1)
     {
        new 
Float:x,Float:y,Float:z;
       
GetPlayerPos(playerid,x,y,z);
       
CreatePickup(123923x,y,z);
       
DestroyDynamic3DTextLabel(houselabel[playerid]);
       return 
1;
    }
    return 
1;

Reply
#4

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
new Text3D:houselabel[MAX_PLAYERS];

PHP код:
CMD:spawnreqhouse(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1)
     {
        new 
Float:x,Float:y,Float:z;
       
GetPlayerPos(playerid,x,y,z);
       
CreatePickup(123923x,y,z);
       
label[playerid] = CreateDynamic3DTextLabel("To request a house at \nthis location, use /requesthouse",COLOR_RED,x,y,z+0.5,4.0);
       return 
1;
    }
    return 
1;

PHP код:
CMD:deletehouse(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1)
     {
        new 
Float:x,Float:y,Float:z;
       
GetPlayerPos(playerid,x,y,z);
       
CreatePickup(123923x,y,z);
       
DestroyDynamic3DTextLabel(houselabel[playerid]);
       return 
1;
    }
    return 
1;

Thanks! but this doesnt destroy the pickup?
Reply
#5

PHP код:
new Text3D:houselabel[MAX_PLAYERS];
new 
housepick;
CMD:spawnreqhouse(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] >= 1
     { 
        new 
Float:x,Float:y,Float:z
       
GetPlayerPos(playerid,x,y,z); 
       
housepick CreatePickup(123923x,y,z); 
       
label[playerid] = CreateDynamic3DTextLabel("To request a house at \nthis location, use /requesthouse",COLOR_RED,x,y,z+0.5,4.0); 
       return 
1
    } 
    return 
1
}  
CMD:deletehouse(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] >= 1
     { 
        new 
Float:x,Float:y,Float:z
       
GetPlayerPos(playerid,x,y,z); 
       
DestroyPickup(housepick); 
       
DestroyDynamic3DTextLabel(houselabel[playerid]); 
       return 
1
    } 
    return 
1

Reply
#6

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
PHP код:
new Text3D:houselabel[MAX_PLAYERS];
new 
housepick;
CMD:spawnreqhouse(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] >= 1
     { 
        new 
Float:x,Float:y,Float:z
       
GetPlayerPos(playerid,x,y,z); 
       
housepick CreatePickup(123923x,y,z); 
       
label[playerid] = CreateDynamic3DTextLabel("To request a house at \nthis location, use /requesthouse",COLOR_RED,x,y,z+0.5,4.0); 
       return 
1
    } 
    return 
1
}  
CMD:deletehouse(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] >= 1
     { 
        new 
Float:x,Float:y,Float:z
       
GetPlayerPos(playerid,x,y,z); 
       
DestroyPickup(housepick); 
       
DestroyDynamic3DTextLabel(houselabel[playerid]); 
       return 
1
    } 
    return 
1

Thanks alot! The one problem here is that with this I will delete all pickups. I am gonna create many pickups so is there a way that I can delete them seperetely? Sorry if I am annyoing +rep
Reply
#7

The command he gave you above will just create many pickup's as you want but it will only delete the last one because the array label[playerid] switches to the last created pickup, to do what you want you should do something like this.

pawn Код:
#include <zcmd>
#include <sscanf2>
#include <streamer>

#define LIMIT 50//change this to your limits..


new
        HousePickup[ LIMIT ],
        Text3D:HouseLabel[ LIMIT ],
        bool:Slots[ LIMIT ] = false;
       
CMD:spawnreqhouse( playerid )
{
    for( new i = 0; i <= LIMIT; i++ )
    {
        if( Slots[ i ] == false )
        {
            //we found free slot
            new
                str[ 64 ], Float:x, Float:y, Float:z ;
            GetPlayerPos( playerid, x, y, z );
            format( str, sizeof( str ), "To request a house at \nthis location, use /requesthouse\nID: %d", i );// so later you can delete by id's.
            HousePickup[ i ] = CreateDynamicPickup( 1239, 23, x, y , z );
            HouseLabel[ i ] = CreateDynamic3DTextLabel( str,-1,x,y,z+0.5,4.0 );
            Slots[ i ] = true;
            break;//stop the loop.
        }
    }
    return true;
}
CMD:deletepickup( playerid, params[] )
{
    new
        id;
    if( sscanf( params, "i", id )) return SendClientMessage( playerid, -1, "Syntax: /deletepickup [id]" );
    if( !IsValidDynamic3DTextLabel( HouseLabel[ id ] ) || !IsValidDynamicPickup( HousePickup[ id ] ) ) return SendClientMessage( playerid, -1, "Not valid." );
    DestroyDynamicPickup( HousePickup[ id ] ) ;
    DestroyDynamic3DTextLabel( HouseLabel[ id ] );
    Slots[ id ] = false;//useable again.
    //deleted.
    return true;
}
Reply
#8

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
The command he gave you above will just create many pickup's as you want but it will only delete the last one because the array label[playerid] switches to the last created pickup, to do what you want you should do something like this.

pawn Код:
#include <zcmd>
#include <sscanf2>
#include <streamer>

#define LIMIT 50//change this to your limits..


new
        HousePickup[ LIMIT ],
        Text3D:HouseLabel[ LIMIT ],
        bool:Slots[ LIMIT ] = false;
       
CMD:spawnreqhouse( playerid )
{
    for( new i = 0; i <= LIMIT; i++ )
    {
        if( Slots[ i ] == false )
        {
            //we found free slot
            new
                str[ 64 ], Float:x, Float:y, Float:z ;
            GetPlayerPos( playerid, x, y, z );
            format( str, sizeof( str ), "To request a house at \nthis location, use /requesthouse\nID: %d", i );// so later you can delete by id's.
            HousePickup[ i ] = CreateDynamicPickup( 1239, 23, x, y , z );
            HouseLabel[ i ] = CreateDynamic3DTextLabel( str,-1,x,y,z+0.5,4.0 );
            Slots[ i ] = true;
            break;//stop the loop.
        }
    }
    return true;
}
CMD:deletepickup( playerid, params[] )
{
    new
        id;
    if( sscanf( params, "i", id )) return SendClientMessage( playerid, -1, "Syntax: /deletepickup [id]" );
    if( !IsValidDynamic3DTextLabel( HouseLabel[ id ] ) || !IsValidDynamicPickup( HousePickup[ id ] ) ) return SendClientMessage( playerid, -1, "Not valid." );
    DestroyDynamicPickup( HousePickup[ id ] ) ;
    DestroyDynamic3DTextLabel( HouseLabel[ id ] );
    Slots[ id ] = false;//useable again.
    //deleted.
    return true;
}
Thanks man.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)