SA-MP Forums Archive
System Privcar - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: System Privcar (/showthread.php?tid=660256)



System Privcar - KamilPolska - 28.10.2018

You know the script for buying private vehicles. For example: In the living room there is an Elegy car and I get in this car and show Dialog. Buy or cancel.


Re: System Privcar - v1k1nG - 28.10.2018

https://sampwiki.blast.hk/wiki/OnPlayerStateChange

PHP код:
// define dialogs first
public OnPlayerStateChange(playeridnewstateoldstate){
    if(
newstate == PLAYER_STATE_DRIVER){ // You need to add another check here so this will be called only in showrooms
        
new string[128], pricecaridmodelid;
        
carid GetPlayerVehicleID(playerid); // Get the vehicle id for future use
        
SetVehicleParamsEx(carid0100000); // ENGINE OFF or player will run away with the car lol
        
modelid GetVehicleModel(carid); // Model id, Elegy is 562
        
switch(modelid){
            case 
562:
            {
                
price 12500;
                
format(stringsizeof string"Elegy1n Price: $%d"price);
                
ShowPlayerDialog(playeridDIALOG_CAR_BUYDIALOG_STYLE_MSGBOX"Buy a car"string"Buy""Cancel");
            }
        }
    }
    return 
1;
 }   
 public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[]){
    switch(
dialogid){
        case 
DIALOG_CAR_BUY:
        {
            if(
response){
                if(
GetPlayerMoney(playerid) < 12500)return ShowPlayerDialog(playeridDIALOG_NO_MONEYDIALOG_STYLE_MSGBOX"Buy a car""You need 12500$ to buy a Elegy!""Ok""");
                
// Take money from player, save player data adding car property etc
                
return 1;
            }
        }
    }
    return 
1;
 } 
Of course this isn't a solution, is simply to give you an idea.