Vice City: Multiplayer

VC:MP Discussion => General Discussion => Topic started by: habi on Jul 31, 2023, 06:14 PM

Title: [Preview]habi's Pickup Binder
Post by: habi on Jul 31, 2023, 06:14 PM
(https://i.imgur.com/4qDuNb2.jpg) (https://i.imgur.com/LZD3JFN.jpg)
(https://i.imgur.com/o4zs9ts.jpg) (https://i.imgur.com/0Jqh0m9.jpg)

What is so special in this?
The code !
function onPlayerCommand(player, cmd, text)
{
    if(cmd=="heal")
    {
        local pickup = CreatePickup(366, player.Pos+Vector(3,3,0));
        player.BindPickup(pickup, function(){
            this.Health=100;//'this' will be player
            pickup.Remove();//because local variable created before function is accessible to the function
            ::ClientMessage("You have been healed!", this, 255, 255, 0);// :: is very important,
            //because the 'this' is instance and not roottable.
        });
        ClientMessage("Health pickup created near you!", player, 255, 0, 255);
    }
}

NB: Only that player who typed /heal will be able to pick_it_up
Download links: attached, and fixed some bugs.(01.08.2023)
Title: Re: [Preview]habi's Pickup Binder
Post by: habi on Aug 01, 2023, 06:46 AM
I tried to reproduce the bug you mentioned. VCMP Server seems to handle this issue.

Not only pickup id, another (3 byte number) is send along with pickup id.

This number is incremented whenever pickup is removed and another one is created.
client->server
b2 00 00 50 00 the b2 is identifier for event, last 00 is pickup id
So this number (hex: 00 00 50) tell server which pickup.

When pickup is removed and created again, the new pickup will have this number
00 00 58, the next one has (00 00 60), the next one (00 00 68) and so on.

I had stopped packets from server to client, removed pickup from server and created another one same id. Since stopped, pickup was not removed for player. I went near and picked that pickup, resumed connection, but onpickup event was not called. Why? this number was changed.

PS: Uploaded the implementation in first post
Title: Re: [Preview]habi's Pickup Binder
Post by: habi on Aug 01, 2023, 03:48 PM
Documentation

PS: There was a small bug onPlayerPart in yesterdays release, and is fixed.
Title: Re: [Preview]habi's Pickup Binder
Post by: Nihongo^ on Aug 01, 2023, 04:23 PM
Isn't players can use it to prevent evading like before the duel they can type /heal, and after losing some hp, take it.