About 3DTextLabel and Timers
#3

Quote:
Originally Posted by nmader
Посмотреть сообщение
Well, what you should do:
pawn Код:
#define MAX_SHELLS 1000 //Or whatever you want the maximum to be.
#define ShellDespawnTime 300000 //Currently 5 minutes, set it to what you want it.

new Text3D:Shell[MAX_SHELLS]; //So each shell has it's own 3DTextLabel.
new ExistentShells; //In order to know which shell is which.
new ShellDespawnTimer[MAX_SHELLS]; //A timer for each shell to despawn
new shellid; //A variable to define shell ID's (used for the timers)

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(weaponid != 24 && weaponid!= 31 && weaponid !=30 && weaponid !=22 && weaponid != 23 && weaponid != 25 && weaponid != 28 && weaponid != 29 && weaponid != 32 && weaponid != 33 && weaponid != 34) return 0; //Making sure only the weapons below create shells (add add onto the variable "ExistentShells"
    ExistentShells++; //Showing how many existent shells there are in order to establish a shell ID
    switch(weaponid)
    {
        case 24: Shell[ExistentShells] = Create3DTextLabel("Desert Eagle Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 31: Shell[ExistentShells] = Create3DTextLabel("M416 Assult rifle Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 30: Shell[ExistentShells] = Create3DTextLabel("AK-47 Assult rifle Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 22: Shell[ExistentShells] = Create3DTextLabel("9MM Pistol Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 23: Shell[ExistentShells] = Create3DTextLabel("9MM Silencer Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 25: Shell[ExistentShells] = Create3DTextLabel("Remington ShotGun Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 28: Shell[ExistentShells] = Create3DTextLabel("UZI SMG Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 29: Shell[ExistentShells] = Create3DTextLabel("MP5 SMG Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 32: Shell[ExistentShells] = Create3DTextLabel("TEC9 SMG Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 33: Shell[ExistentShells] = Create3DTextLabel("Contry Rifle Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
        case 34: Shell[ExistentShells] = Create3DTextLabel("Sniper Rifle Shell", COLOR_GREY, X, Y, Z, 30.0, 0, 0);
    }
    shellid = ExistentShells;
    ShellDespawnTimer[shellid] = SetTimerEx("ShellDespawn", ShellDespawnTime, false, "i", shellid);
    return 1;
}

forward ShellDespawn(shellid);
public ShellDespawn(shellid)
{
    Delete3DTextLabel(Shell[shellid]);
    return 1;
}
Lemme know if there are any bugs. This is untested and I just wrote the code here, in ****** Chrome.
Here is a warning I got
Quote:

warning 219: local variable "shellid" shadows a variable at a preceding level
the line : public ShellDespawn(shellid)

Reply


Messages In This Thread
About 3DTextLabel and Timers - by DemME - 13.06.2014, 03:30
Re: About 3DTextLabel and Timers - by nmader - 13.06.2014, 04:04
Re: About 3DTextLabel and Timers - by DemME - 13.06.2014, 04:38
Re: About 3DTextLabel and Timers - by nmader - 13.06.2014, 04:47
Re: About 3DTextLabel and Timers - by DemME - 13.06.2014, 05:16
Re: About 3DTextLabel and Timers - by nmader - 13.06.2014, 05:39

Forum Jump:


Users browsing this thread: 1 Guest(s)