PDA

View Full Version : Carshop System [DM server]


salev13
08/05/2014, 11:37 AM
I got one filterscript for that but when someone buy the car this is dosent spend money and when he sell it
the money is showing up and after he's down back to the same number he was got in the start

This is the pawn codes:

#include <a_samp>
#include <dof2>
#pragma unused DOF2_Exit
#include <cpstream>

#define DIALOG_CAR (120)

enum pInfoVehicle
{
vehicle_Name[30],
vehicle_Price,
vehicle_ID
};

new PlayerData[][pInfoVehicle] =
{
{"Sultan", 500000, 560},
{"Infernus", 1000000, 411},
{"Washington", 350000, 421},
{"Stallion", 400000, 439},
{"Romero", 450000, 442},
{"Admiral", 350000, 445},
{"Turismo", 1000000, 451},
{"Faggio", 150000, 462},
{"Freeway", 250000, 463},
{"NRG-500", 500000, 522}
};

new pName[MAX_PLAYERS][MAX_PLAYER_NAME+1], vehicle_CP, vehicle_Create[MAX_PLAYERS], bool: vehicle_In[MAX_PLAYERS], Text3D:vehicle_Text3D[MAX_VEHICLES];

public OnGameModeInit()
{
vehicle_CP = CPS_AddCheckpoint(2096.5759, 1284.1421, 10.8203 ,2.0, 40);
return 1;
}

public OnPlayerConnect(playerid) return GetPlayerName(playerid, pName[playerid], MAX_PLAYER_NAME+1), 1;
public OnPlayerDisconnect(playerid, reason)
{
if(vehicle_In[playerid] == true)
{
DestroyVehicle(vehicle_Create[playerid]), vehicle_In[playerid] = false;
Delete3DTextLabel(vehicle_Text3D[vehicle_Create[playerid]]);
}
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/carshop", true))
{
SetPlayerPos(playerid, 2096.5759, 1284.1421, 10.8203);
return SendClientMessage(playerid, 0xFFFF00FF, ".ברוכים הבאים לחנות הרכבים");
}

if(!strcmp(cmdtext, "/callcar", true))
{
if(!DOF2_GetBool(VehicleFile(playerid), "VehicleHave")) return SendClientMessage(playerid, 0xFF0000FF, ".לא קיים רכב בבעלותך");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, ".אתה כבר נמצא בתוך רכב");
vehicle_Create[playerid] = CreateVehicle(DOF2_GetInt(VehicleFile(playerid), "VehicleModel"), 0.0, 0.0, 0.0, 0.0, -1, -1, 60);
new Float:vehicle_Pos[4];
GetPlayerPos(playerid, vehicle_Pos[0], vehicle_Pos[1], vehicle_Pos[2]);
SetVehiclePos(vehicle_Create[playerid], vehicle_Pos[0], vehicle_Pos[1], vehicle_Pos[2]);
PutPlayerInVehicle(playerid, vehicle_Create[playerid], 0);
new Vehicle_F[50];
format(Vehicle_F, sizeof(Vehicle_F), "{CCFF66}%s {FF0066}:הבעלים של הרכב", pName[playerid]);
vehicle_Text3D[vehicle_Create[playerid]] = Create3DTextLabel(Vehicle_F, 0xFFFF00FF, 0, 0, 0, 30, 0, 0);
Attach3DTextLabelToVehicle(vehicle_Text3D[vehicle_Create[playerid]], vehicle_Create[playerid], 0, 0, 1);
vehicle_In[playerid] = true;
return SendClientMessage(playerid, 0xFFFF00FF, ".רכבך שוגר אליך נהג בזהירות"), 1;
}

if(!strcmp(cmdtext,"/sellcar", true))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, ".אתה לא נמצא בתוך רכב");
if(!DOF2_GetBool(VehicleFile(playerid), "VehicleHave")) return SendClientMessage(playerid, 0xFF0000FF, ".לא קיים רכב בבעלותך");
GivePlayerMoney(playerid, DOF2_GetInt(VehicleFile(playerid), "VehiclePrice") / 2);
if(vehicle_In[playerid] == true)
DestroyVehicle(vehicle_Create[playerid]), vehicle_In[playerid] = false;
Delete3DTextLabel(vehicle_Text3D[vehicle_Create[playerid]]);
DOF2_RemoveFile(VehicleFile(playerid));
return SendClientMessage(playerid, 0xFFFF00FF, ".רכבך נמכר וקיבלת חצי ממחירו"), 1;
}
return 0;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicle_In[playerid] == true)
{
DestroyVehicle(vehicle_Create[playerid]), vehicle_In[playerid] = false;
Delete3DTextLabel(vehicle_Text3D[vehicle_Create[playerid]]);
}
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER && vehicle_In[playerid])
{
DestroyVehicle(vehicle_Create[playerid]), vehicle_In[playerid] = false;
Delete3DTextLabel(vehicle_Text3D[vehicle_Create[playerid]]);
}
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
if(vehicle_In[killerid] == true)
{
DestroyVehicle(vehicle_Create[killerid]), vehicle_In[killerid] = false;
Delete3DTextLabel(vehicle_Text3D[vehicle_Create[killerid]]);
}
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if(CPS_IsPlayerInCheckpoint(playerid, vehicle_CP) && !IsPlayerInAnyVehicle(playerid))
{
new string[600];
format(string, sizeof(string), "");
for(new i; i <sizeof(PlayerData); i++)
{
format(string, sizeof(string), "%s\n{FF00FF}Vehicle Name: [%s] {FFFF00}Price:[$%d]", string, PlayerData[i][vehicle_Name], PlayerData[i][vehicle_Price]);
}
ShowPlayerDialog(playerid, DIALOG_CAR, DIALOG_STYLE_LIST, "{C0C0C0}חנות המכוניות", string, "קנייה", "יציאה");
}
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CAR)
{
if(!response) return 0;
if(DOF2_GetBool(VehicleFile(playerid), "VehicleHave")) return SendClientMessage(playerid, 0xFF0000FF, ".קיים כבר רכב בבעלותך");
DOF2_CreateFile(VehicleFile(playerid));
if(GetPlayerMoney(playerid) < PlayerData[listitem][vehicle_Price]) return SendClientMessage(playerid, 0xFF0000FF, ".אין בידך את הכסף הדרוש");
GivePlayerMoney(playerid, -PlayerData[listitem][vehicle_Price]);
DOF2_SetString(VehicleFile(playerid), "VehicleName", PlayerData[listitem][vehicle_Name]);
DOF2_SetInt(VehicleFile(playerid), "VehiclePrice", PlayerData[listitem][vehicle_Price]);
DOF2_SetInt(VehicleFile(playerid), "VehicleModel", PlayerData[listitem][vehicle_ID]);
DOF2_SetBool(VehicleFile(playerid), "VehicleHave", true);
DOF2_SaveFile();
SendClientMessage(playerid, 0xFFFF00FF, ".מזל טוב, כעת יש בבעלותך רכב");
}
return 1;
}

stock VehicleFile(playerid)
{
new v_File[64];
format(v_File, sizeof(v_File), "%s.ini", pName[playerid]);
return v_File;
}