Pickup on top of player
#1

[ame="http://www.youtube.com/watch?v=WJVXrcblNkY"]http://www.youtube.com/watch?v=WJVXrcblNkY[/ame]
When the player takes damage appears a weapon on top of it how do I this?
Reply
#2

You have to check if the player change the weapon
then attach a object top of the player for the time you need
Reply
#3

I do not get any tutorial?
Reply
#4

pawn Код:
enum WTOOBJ {
    Weaponid,
    Objectid
}
new WeaponIdToObject[][WTOOBJ] = {
    { 1, 331},
    { 2, 333},
    { 3, 334},
    { 4, 335},
    { 5, 336},
    { 6, 337},
    { 7, 338},
    { 8, 339},
    { 9, 341},
    { 10, 321},
    { 11, 322},
    { 12, 323},
    { 13, 324},
    { 14, 325},
    { 15, 326},
    { 16, 342},
    { 17, 343},
    { 18, 344},
    { 22, 346},
    { 23, 347},
    { 24, 348},
    { 25, 349},
    { 26, 350},
    { 27, 351},
    { 28, 352},
    { 29, 353},
    { 30, 355},
    { 31, 356},
    { 32, 372},
    { 33, 357},
    { 34, 358},
    { 35, 359},
    { 36, 360},
    { 37, 361},
    { 38, 362},
    { 39, 363},
    { 40, 364},
    { 41, 365},
    { 42, 366},
    { 43, 367},
    { 44, 368},
    { 45, 369},
    { 46, 371}
};



stock OnPlayerChangeWeapon(playerid, oldweapon, newweapon)
{
    for(new w = 0; w != sizeof(WeaponIdToObject); w++) {
        if(newweapon ==  WeaponIdToObject[w][Weaponid]) {
            //Attach the oject where you want wit the modelid = WeaponIdToObject[w][Objectid]
            //then set some timers for disappear and a queue variable :D
        }
    }
}
Somthing like that lol

For taht function https://sampwiki.blast.hk/wiki/OnPlayerUpdate

This make the weapon appear on weapon change but are you sure in the video when player take damage?
it sems appear when player change a weapon

anyway use OnPlayerTakeDamage insteead of taht function
Reply
#5

Why do you even want that LOL.
Reply
#6

Maybe for a dm server?
Reply
#7

That should do what you want.

Код:
new PlayerObj [MAX_PLAYERS];
new ObjTimer [MAX_PLAYERS];
stock GetWeaponModel(weaponid)
{
    new model;

    switch(weaponid)
    {
        case 1: model=331; case 2: model=333; case 3: model=334;
        case 4: model=335; case 5: model=336; case 6: model=337;
        case 7: model=338; case 8: model=339; case 9: model=341;
        case 10: model=321; case 11: model=322; case 12: model=323;
        case 13: model=324; case 14: model=325; case 15: model=326;
        case 16: model=342; case 17: model=343; case 18: model=344;
        case 22: model=346; case 23: model=347; case 24: model=348;
        case 25: model=349; case 26: model=350; case 27: model=351;
        case 28: model=352; case 29: model=353; case 30: model=355;
        case 31: model=356; case 32: model=372; case 33: model=357;
        case 34: model=358; case 35: model=359; case 36: model=360;
        case 37: model=361; case 38: model=362; case 39: model=363;
        case 41: model=365; case 42: model=366; case 46: model=371;
    }
    return model;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
KillTimer (ObjTimer [playerid]);
PlayerObj [playerid] = CreateObject ( GetWeaponModel (weaponid), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 200.0 );
AttachObjectToPlayer(PlayerObj [playerid], playerid, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0);
ObjTimer [playerid] = SetTimerEx("DestroyPlayerObj", 2000, 0, "i", playerid);
return 1;
}

forward DestroyPlayerObj(playerid);
public DestroyPlayerObj(playerid) {
DestroyObject (PlayerObj[playerid]);
}
https://sampwiki.blast.hk/wiki/AttachObjectToPlayer
https://sampwiki.blast.hk/wiki/CreateObject
https://sampwiki.blast.hk/wiki/SetTimerEx
https://sampwiki.blast.hk/wiki/KillTimer
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
Reply
#8

This will call a Timer every single hit, and the timer will be replaced with the new one every single hit i think you must add a queue variable
Reply
#9

The timer is used to remove the object after 2 secs, ofc every hit the old timer should be killed cuz the new object should be above his head for other 2 secs.
Reply
#10

pawn Код:
new PlayerObj [MAX_PLAYERS];
new ObjTimer [MAX_PLAYERS];
stock GetWeaponModel(weaponid)
{
    new model;

    switch(weaponid)
    {
        case 1: model=331; case 2: model=333; case 3: model=334;
        case 4: model=335; case 5: model=336; case 6: model=337;
        case 7: model=338; case 8: model=339; case 9: model=341;
        case 10: model=321; case 11: model=322; case 12: model=323;
        case 13: model=324; case 14: model=325; case 15: model=326;
        case 16: model=342; case 17: model=343; case 18: model=344;
        case 22: model=346; case 23: model=347; case 24: model=348;
        case 25: model=349; case 26: model=350; case 27: model=351;
        case 28: model=352; case 29: model=353; case 30: model=355;
        case 31: model=356; case 32: model=372; case 33: model=357;
        case 34: model=358; case 35: model=359; case 36: model=360;
        case 37: model=361; case 38: model=362; case 39: model=363;
        case 41: model=365; case 42: model=366; case 46: model=371;
    }
    return model;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
DestroyPlayerObj(playerid);
KillTimer (ObjTimer [playerid]);
PlayerObj [playerid] = CreateObject ( GetWeaponModel (weaponid), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 200.0 );
AttachObjectToPlayer(PlayerObj [playerid], playerid, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0);
ObjTimer [playerid] = SetTimerEx("DestroyPlayerObj", 2000, 0, "i", playerid);
return 1;
}

forward DestroyPlayerObj(playerid);
public DestroyPlayerObj(playerid) {
DestroyObject (PlayerObj[playerid]);
}
correct code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)