Trunk system
#7

Here is code:

pawn Код:
//put those at the top of OnGamemodeInit
new VTrunk[MAX_VEHICLES];

forward Float:GetXYBehindCar(vid, &Float:q, &Float:w, Float:distance);
Float:GetXYBehindCar(vid, &Float:q, &Float:w, Float:distance)
{
    new Float:a;
    GetVehiclePos(vid, q, w, a);
    GetVehicleZAngle(vid, a);
    q += (distance * -floatsin(-a, degrees));
    w += (distance * -floatcos(-a, degrees));
    return a;
}

//put this in OnPlayerCommandText
if (strcmp(cmd, "/trunk", true, 10) == 0)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));

        for(new vid; vid<MAX_VEHICLES; vid++)
        {
            new Float: vx, Float:vy, Float:vz;
            GetVehiclePos(vid,vx,vy,vz);
            GetXYBehindCar(vid, vx, vy, 3.5);
            if(IsPlayerInRangeOfPoint(playerid,2.5,vx,vy,vz))
            {
                new e,l,a,d,b,bo,o;
                GetVehicleParamsEx(vid,e,l,a,d,b,bo,o);
                switch(VTrunk[vid])
                {
                    case 0:
                    {
                            GetPlayerPos(playerid,px[playerid],py[playerid],pz[playerid]);
                            SetVehicleParamsEx(vid,e,l,a,d,b,1,o);
                            VTrunk[vid]=1;
                            new lockmsg[256];
                            format(lockmsg,sizeof(lockmsg),"* %s has opened the trunk of their vehicle.",name);
                            for(new Player; Player < MAX_PLAYERS; Player++)
                            {
                                if(IsPlayerInRangeOfPoint(Player,15,px[playerid],py[playerid],pz[playerid]))
                                {
                                    SendClientMessage(Player,0xC2A2DAAA,lockmsg);
                                }
                            }
                    }
                    case 1:
                    {
                        GetPlayerPos(playerid,px[playerid],py[playerid],pz[playerid]);
                        SetVehicleParamsEx(vid,e,l,a,d,b,0,o);
                        VTrunk[vid]=0;
                        new lockmsg[256];
                        format(lockmsg,sizeof(lockmsg),"* %s has closed the trunk of their vehicle.",name);
                        for(new Player; Player < MAX_PLAYERS; Player++)
                        {
                            if(IsPlayerInRangeOfPoint(Player,15,px[playerid],py[playerid],pz[playerid]))
                            {
                                SendClientMessage(Player,0xC2A2DAAA,lockmsg);
                            }
                        }
                    }
                }
            }
        }
        return 1;
    }
Reply


Messages In This Thread
Trunk system - by david1236 - 09.12.2010, 09:21
Re: Trunk system - by GooMan - 09.12.2010, 09:36
Re: Trunk system - by david1236 - 09.12.2010, 09:46
Re: Trunk system - by Kastranova - 09.12.2010, 13:58
Re: Trunk system - by Scenario - 09.12.2010, 14:08
Re: Trunk system - by david1236 - 09.12.2010, 17:33
Re: [SOLVED]Trunk system - by Amora187 - 29.06.2012, 22:42
Re: Trunk system - by Luis- - 29.06.2012, 22:51
Re: [SOLVED]Trunk system - by Amora187 - 30.06.2012, 15:39

Forum Jump:


Users browsing this thread: 1 Guest(s)