System Privcar
#1

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.
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)