Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Dialog help

$
0
0
hey I have this command
PHP Code:

CMD:resetcar(playeridparams[])
{
    new 
playername[25], string[256], giveplayeridmoneys1tmp[256],str[130], slot=-1loc=-1;
    if (
PlayerVehicles(playerid) > 1)
    {
        if(
sscanf(params"i"slot)) return SendClientMessage2(playeridCOLOR_WHITE"Usage: /resetcar [slot]") && SendClientMessage2(playeridCOLOR_WHITE"See your slots by using /myvehs");
    }
    else if (
PlayerVehicles(playerid) == 1slot=0;
    else return 
SendClientMessage2(playeridCOLOR_RED"Error: You do not own a vehicle!");
    if(
slot || slot MaxOwnVehs(playerid)) return SendClientMessage2(playeridCOLOR_RED"Error: That slot doesn't exist!");
    if (!
PlayerVehicleIS(playeridslot)) return SendClientMessage2(playeridCOLOR_RED"Error: You do not own a vehicle in that slot!");
    if (
IsPlayerInVehicle(playeridpvehicle[playerid][0][slot])) return SendClientMessage2(playeridCOLOR_SILVER"Your vehicle doesn't need relocating, you are in it!");
    if (
GetVehicleHealth2(pvehicle[playerid][0][slot]) == 100.0) return SendClientMessage2(playeridCOLOR_RED"Your vehicle can't be reset due to the damage.");

    
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
    new 
tvar1 dini_Int(AddDirFile(dir_userfilesplayername), "propowned")-1;
    new 
tvar12 dini_Int(AddDirFile(dir_userfilesplayername), "busowned")-1;

    
ResetCarSlot[playerid] = slot;

    
format(string50"V_%s_%d"playernameslot);
    new 
tvar2 dini_Int(AddDirFile(dir_carfilesstring), "model");

    if (
tvar1 != -&& tvar12 == -&& loc == -1)
    {
        if (
DoesPlayerHaveMenuOpen(playerid) || GetPlayerDialog(playerid) != -1)    return SendClientMessage2(playeridCOLOR_WHITE"SERVER: Please exit your current menu first.");
        
ShowPlayerDialog2(playeridDIALOG_RESET_CARDIALOG_STYLE_LIST"Where do you want to reset your car?""Police Department\nYour Property""Select""Cancel");
        return 
1;
    }
    else if (
tvar12 != -&& tvar1 == -&& loc == -1)
    {
        if (
DoesPlayerHaveMenuOpen(playerid) || GetPlayerDialog(playerid) != -1)    return SendClientMessage2(playeridCOLOR_WHITE"SERVER: Please exit your current menu first.");
        
ShowPlayerDialog2(playeridDIALOG_RESET_CAR3DIALOG_STYLE_LIST"Where do you want to reset your car?""Police Department\nYour Business""Select""Cancel");
        return 
1;
    }
    else if(
tvar12 != -&& tvar1 != -&& loc == -1)
    {
        if (
DoesPlayerHaveMenuOpen(playerid) || GetPlayerDialog(playerid) != -1)    return SendClientMessage2(playeridCOLOR_WHITE"SERVER: Please exit your current menu first.");
        
ShowPlayerDialog2(playeridDIALOG_RESET_CAR2DIALOG_STYLE_LIST"Where do you want to reset your car?""Police Department\nYour Property\nYour Business""Select""Cancel");
        return 
1;
    }
    new 
panelsdoorslightstiresFloat:health;

    if (
tvar1 == -|| tvar12 != -1) {
        new 
tvar3tvar4tvar5Float:xFloat:yFloat:zFloat:a;
        
giveplayerid = -1;
        
tvar5 vehstored[pvehicle[playerid][0][slot]];
        if (
tvar5 != -1) {
            
holdsv[tvar5] = 0;
            
vehstored[pvehicle[playerid][0][slot]] = -1;
        }
        if (
GetPlayerInterior(playerid) != 0) {
            new 
shamalid GetPlayerShamalID(playerid);
            if (
shamalid != && GetVehicleInterior(shamalid) == 0) {
                
GetVehiclePos(shamalidxyz);
            }
            else {
                
adata[plastdoor[playerid]][ax];
                
adata[plastdoor[playerid]][ay];
                
adata[plastdoor[playerid]][az];
            }
        }
        else {
            
GetPlayerPos(playeridxyz);
        }
        for (new 
0sizeof(pdCoords); d++) {
            if (
PointToPoint2D(xypdCoords[d][0], pdCoords[d][1]) <= PointToPoint2D(xypdCoords[tvar3][0], pdCoords[tvar3][1])) {
                
tvar4 = -1;
                for (new 
0sizeof(pdCarCoords); b++) {
                    if (
pdCarCoords[b][4] == d+&& holdsv[b] == 0) {
                        
tvar4 b;
                        break;
                    }
                }
                if (
tvar4 != -1) {
                    
giveplayerid d;
                    
moneys1 tvar4;
                }
                
tvar3 d;
            }
        }
        if (
giveplayerid == -1) {
            
ResetCarSlot[playerid] = -1;
            return 
SendClientMessage2(playeridCOLOR_WHITE"Sorry there are no spaces available to relocate your vehicle.");
        }

        if (
tvar2 == 457 || tvar2 == 596 || tvar2 == 597 || tvar2 == 598) {
            for (new 
0playercount=GetPlayerPoolSize(); <= playercounti++) {
                
format(tmp12"hpevsp%d"pvehicle[playerid][0][slot]);
                if (
GetPVarInt(itmp) == 1) {
                    
SetPVarInt(itmp0);
                }
            }
        }

        if (
bootdcp[pvehicle[playerid][0][slot]] != 0) {
            
DestroyDynamicCP(bootdcp[pvehicle[playerid][0][slot]]);
            for (new 
0playercount=GetPlayerPoolSize(); <= playercounti++) {
                if (
IsPlayerConnected2(i) && pdynamiccp[i] == bootdcp[pvehicle[playerid][0][slot]]) {
                    
CallLocalFunction("OnPlayerLeaveDynamicCP""dd"ipdynamiccp[i]);
                }
            }
            
cptype[bootdcp[pvehicle[playerid][0][slot]]][0] = 0;
            
cptype[bootdcp[pvehicle[playerid][0][slot]]][1] = -1;
            
bootdcp[pvehicle[playerid][0][slot]] = 0;
        }

        if (
tvar5 == -&& GetVehicleVirtualWorld(pvehicle[playerid][0][slot]) == 0) {
            
GetVehiclePos(pvehicle[playerid][0][slot], xyz);
            
GetVehicleZAngle(pvehicle[playerid][0][slot], a);
            
dini_FloatSet(AddDirFile(dir_carfilesstring), "X"x);
            
dini_FloatSet(AddDirFile(dir_carfilesstring), "Y"y);
            
dini_FloatSet(AddDirFile(dir_carfilesstring), "Z"z);
            
dini_FloatSet(AddDirFile(dir_carfilesstring), "A"a);
        }

        new 
temp1 pvehicle[playerid][0][slot];
        new 
temp2 GetVehicleModel(temp1);

        if (
tvar2 == temp2) {
            
GetVehicleDamageStatus(pvehicle[playerid][0][slot], panelsdoorslightstires);
            
dini_IntSet(AddDirFile(dir_carfilesstring), "panels"panels);
            
dini_IntSet(AddDirFile(dir_carfilesstring), "doors"doors);
            
dini_IntSet(AddDirFile(dir_carfilesstring), "lights"lights);
            
dini_IntSet(AddDirFile(dir_carfilesstring), "tires"tires);
        }
        else {
            
vmodelused[temp2-400] --;
            if (
vmodelused[temp2-400] == 0vehiclemodels --;

            
dini_IntSet(AddDirFile(dir_carfilesstring), "panels"0);
            
dini_IntSet(AddDirFile(dir_carfilesstring), "doors"0);
            
dini_IntSet(AddDirFile(dir_carfilesstring), "lights"0);
            
dini_IntSet(AddDirFile(dir_carfilesstring), "tires"0);
        }

        
GetVehicleHealth(pvehicle[playerid][0][slot], health);
        
dini_FloatSet(AddDirFile(dir_carfilesstring), "health"health-1000);

        
DestroyVehicle(pvehicle[playerid][0][slot]);
        
pvehicle[playerid][0][slot] = CreateVehicle(tvar2pdCarCoords[moneys1][0], pdCarCoords[moneys1][1], pdCarCoords[moneys1][2], pdCarCoords[moneys1][3], vehcol[pvehicle[playerid][0][slot]][0], vehcol[pvehicle[playerid][0][slot]][1], -1);

        if (
pvehicle[playerid][0][slot] != temp1) {
            
vehcol[pvehicle[playerid][0][slot]][0] = vehcol[temp1][0];
            
vehcol[pvehicle[playerid][0][slot]][1] = vehcol[temp1][1];
            
vehcol[temp1][0] = 0;
            
vehcol[temp1][1] = 0;
            if (
bootdata[temp1][0][0] != 0)
            {
                
bootdata[pvehicle[playerid][0][slot]][0][0] = bootdata[temp1][0][0];
                
bootdata[temp1][0][0] = 0;
                
bootdata[pvehicle[playerid][0][slot]][0][1] = bootdata[temp1][0][1];
                
bootdata[temp1][0][1] = 0;
                
bootdata[pvehicle[playerid][0][slot]][0][2] = bootdata[temp1][0][2];
                
bootdata[temp1][0][2] = 0;
                
bootdata[pvehicle[playerid][0][slot]][0][3] = bootdata[temp1][0][3];
                
bootdata[temp1][0][3] = 0;
                
bootdata[pvehicle[playerid][0][slot]][0][4] = bootdata[temp1][0][4];
                
bootdata[temp1][0][4] = 0;
            }
            if (
bootdata[temp1][1][0] != 0)
            {
                
bootdata[pvehicle[playerid][0][slot]][1][0] = bootdata[temp1][1][0];
                
bootdata[temp1][1][0] = 0;
                
bootdata[pvehicle[playerid][0][slot]][1][1] = bootdata[temp1][1][1];
                
bootdata[temp1][1][1] = 0;
                
bootdata[pvehicle[playerid][0][slot]][1][2] = bootdata[temp1][1][2];
                
bootdata[temp1][1][2] = 0;
                
bootdata[pvehicle[playerid][0][slot]][1][3] = bootdata[temp1][1][3];
                
bootdata[temp1][1][3] = 0;
                
bootdata[pvehicle[playerid][0][slot]][1][4] = bootdata[temp1][1][4];
                
bootdata[temp1][1][4] = 0;
            }
            if (
plockedveh[playerid] == temp1) {
                for (new 
0playercount=GetPlayerPoolSize(); <= playercounti++) {
                    if (
!= playerid) {
                        
vehiclelocked[i][temp1] = false;
                        
vehiclelocked[i][pvehicle[playerid][0][slot]] = true;
                    }
                }
                
plockedveh[playerid] = pvehicle[playerid][0][slot];
            }
            
Gas[pvehicle[playerid][0][slot]] = Gas[temp1];
            
Gas[temp1] = FuelMax;
        }
//
        
SetVehicleHealth(pvehicle[playerid][0][slot], health);
        if (
tvar2 == temp2) {
            
UpdateVehicleDamageStatus(pvehicle[playerid][0][slot], panelsdoorslightstires);
        }
        for (new 
0CAR_MOD_SLOTSd++) {
            
format(tmp24"mod_s%d"d);
            if (
dini_Isset(AddDirFile(dir_carfilesstring), tmp)) {
                
AddVehicleComponent(pvehicle[playerid][0][slot], dini_Int(AddDirFile(dir_carfilesstring), tmp));
            }
        }
        if (
dini_Isset(AddDirFile(dir_carfilesstring), "paintjob")) {
            
ChangeVehiclePaintjob(pvehicle[playerid][0][slot], dini_Int(AddDirFile(dir_carfilesstring), "paintjob"));
        }
        if (
dini_Isset(AddDirFile(dir_carfilesstring), "lplate")) {
            if (
dini_Isset(AddDirFile(dir_carfilesstring), "platecolor")) {
                
format(tmp32"{%s}%s"dini_Get(AddDirFile(dir_carfilesstring), "platecolor"), dini_Get(AddDirFile(dir_carfilesstring), "lplate"));
                
SetVehicleNumberPlate2(pvehicle[playerid][0][slot], tmp);
            }
            else {
                
SetVehicleNumberPlate2(pvehicle[playerid][0][slot], dini_Get(AddDirFile(dir_carfilesstring), "lplate"));
            }
        }
        
vehstored[pvehicle[playerid][0][slot]] = moneys1;
        
holdsv[moneys1] = pvehicle[playerid][0][slot];
        if( 
dini_Int(AddDirFile(dir_carfilesstring), "nenon11") || dini_Int(AddDirFile(dir_carfilesstring), "nenon12"))
        {
            
dini_IntSet(AddDirFile(dir_userfilesplayername), "Neon"0);
            
DestroyObject(obj3[pvehicle[playerid][0][slot]]);
            
DestroyObject(obj4[pvehicle[playerid][0][slot]]);
            
dini_Unset(AddDirFile(dir_carfilesstring), "nenon11");
            
dini_Unset(AddDirFile(dir_carfilesstring), "nenon12");
            
obj3[pvehicle[playerid][0][slot]] = 0;
            
obj4[pvehicle[playerid][0][slot]] = 0;
        }
        
format(string128"Your %s has been allocated to %s."vehName[tvar2-400], pdNames[giveplayerid]);
        
SendClientMessage2(playeridCOLOR_ORANGEstring);
        
ResetCarSlot[playerid] = -1;
    }
    
printf("[resetcar] %s (Id%d) has reset their vehicle."playernameplayerid);
    return 
1;


PHP Code:

stock UpdatePlayerVehicleSlots(player)
{
    new 
str[128], str2[128], playername[25];
    
GetPlayerName(playerplayername25);
    for(new 
ipv=0ipv<MaxOwnVehs(player); ipv++)
    {
        
format(strsizeof(str), "V_%s_%d"playernameipv);
        if(!
dini_Exists(AddDirFile(dir_carfilesstr)))
        {
            for(new 
i=ipv+1i<MaxOwnVehs(player); i++)
            {
                
format(str2sizeof(str2), "V_%s_%d"playernamei);
                if(
dini_Exists(AddDirFile(dir_carfilesstr2)))
                {
                    
DINI_frenametextfile(AddDirFile(dir_carfilesstr2), AddDirFile(dir_carfilesstr));
                    
pvehicle[player][0][ipv] = pvehicle[player][0][i];
                    
pvehicle[player][0][i]=0;
                    break;
                }
            }
        }
    }
}
stock PlayerVehicle(playervehid)
{
    new 
pveh=-1;
    for(new 
ipv=0ipv<MaxOwnVehs(player); ipv++)
    {
        if(
pvehicle[player][0][ipv] == vehid)
        {
            
pveh=ipv;
            break;
        }
    }
    return 
pveh;
}
stock PlayerVehicleIS(playerslot)
{
    if(
pvehicle[player][0][slot] > 0) return 1;
    return 
0;
}
stock PlayerVehicleLeft(player)
{
    new 
pveh=-1;
    for(new 
ipv=MaxOwnVehs(player)-1ipv>=0ipv--)
    {
        new 
str[128];
        
GetPlayerName(playerstr25);
        
format(strsizeof(str), "V_%s_%d"stripv);
        if(!
dini_Exists(AddDirFile(dir_carfilesstr))) pveh=ipv;
    }
    return 
pveh;
}
stock PlayerVehicles(player)
{
    new 
pveh=0;
    for(new 
ipv=0ipv<MaxOwnVehs(player); ipv++)
    {
        new 
str[128];
        
GetPlayerName(playerstr25);
        
format(strsizeof(str), "V_%s_%d"stripv);
        if(
dini_Exists(AddDirFile(dir_carfilesstr))) pveh++;
    }
    return 
pveh;
}
stock MaxOwnVehs(player)
{
    new 
amount=1;
    if(
vipmember[player]==2amount 6;
    else if(
vipmember[player]==1amount 3;
    return 
amount;


I wanna turn it to be on dialog which show me the cars he own and when I press on one it resets the correct one ho tow do that? can anyone help

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>