Üdv áthoztam 1 scriptet a HIV.FÓRUMRÓL .
Készitõ:[PC]henkie[NL]
Szükséges Include Hozzá még :
http://forum.sa-mp.com/showthread.php?t=175565Eredeti Link
:http://forum.sa-mp.com/showthread.php?t=299761Képek:
Nappal:
Este:
Script:
[pawn]//=============================================================================
// CARAVAN SCRIPT BY HENK ©2011
// DO NOT REMOVE THIS CREDITS!
//=============================================================================
// ONLY EDIT THIS PART OF THE SCRIPT
#define SMALL_CARAVAN_PRICE 15000 //Changes the price for a small caravan.
#define BIG_CARAVAN_PRICE 20000 //Changes the price for a big caravan.
#define DEALER_XPOS 1687.0305 //Changes the dealership x-pos
#define DEALER_YPOS 1855.0242 //Changes the dealership y-pos
#define DEALER_ZPOS 10.6638 //Changes the dealership z-pos
// END OF THE EDIT PART
//=============================================================================
//Includes
#include <a_samp>
#include <YSI\\y_ini>
//=============================================================================
//Defines
#define DIALOG_BUYC 70
#define DIALOG_CONFIRMC 71
#define PATH \"Caravans/%s.ini\"
#define COLOR_RED 0xFF0000FF
//=============================================================================
//Forwards
forward LoadCaravans_data(playerid, name[], value[]);
//=============================================================================
//Vars
new Caravan[MAX_PLAYERS];
new CaravanChoise[MAX_PLAYERS];
new vehicleid;
enum cInfo
{
cModel,
Float:cXpos,
Float:cYpos,
Float:cZpos,
Float:cRotation,
cOwner[64],
cAmount
}
new CaravanInfo[MAX_PLAYERS][cInfo];
//=============================================================================
public OnFilterScriptInit()
{
CreatePickup(1318, 0, DEALER_XPOS, DEALER_YPOS, DEALER_ZPOS, -1);
print(\"\\n======================================\");
print(\"| Caravan Script 3.2 by Henk |\");
print(\"======================================\\n\");
return 1;
}
//=============================================================================
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(\"/attach\", cmdtext, true, 10) == 0)
{
new Float:pos[3];
GetVehiclePos(GetPlayerVehicleID(playerid), pos[0], pos[1], pos[2]);
vehicleid = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicleid);
if( model== 592 || model== 577 || model== 511 || model== 512 || model== 593 || model== 520 || model== 553 || model== 476 || model== 519 || model== 460
|| model== 513 || model== 548 || model== 425 || model== 417 || model== 487 || model== 488 || model== 497 || model== 563 || model== 447
|| model== 469 || model== 509 || model== 481 || model== 510 || model== 462 || model== 448 || model== 581 || model== 522 || model== 461
|| model== 521 || model== 523 || model== 463 || model== 586 || model== 468 || model== 471 || model== 472 || model== 473 || model== 493
|| model== 595 || model== 484 || model== 430 || model== 453 || model== 452 || model== 446 || model== 454 )
{
SendClientMessage(playerid, COLOR_RED, \"Nem tudsz erre a jármüre karavánt rakni!!\");
}
else
{
if(CaravanInfo[playerid][cModel] == 3172)
{
if(IsPlayerInRangeOfPoint(playerid, 25.0, CaravanInfo[playerid][cXpos], CaravanInfo[playerid][cYpos], CaravanInfo[playerid][cZpos]))
{
AttachObjectToVehicle(Caravan[playerid], vehicleid, 0.0, -8.7, -0.8, 0.0, 0.0, 180);
}
}
else
{
if(IsPlayerInRangeOfPoint(playerid, 25.0, CaravanInfo[playerid][cXpos], CaravanInfo[playerid][cYpos], CaravanInfo[playerid][cZpos]))
{
AttachObjectToVehicle(Caravan[playerid], vehicleid, 0.0, -7.2, -0.8, 0.0, 0.0, 180);
}
}
}
return 1;
}
else if(strcmp(\"/detach\", cmdtext, true, 10) == 0)
{
new Float:pos[4];
GetVehiclePos(GetPlayerVehicleID(playerid), pos[0], pos[1], pos[2]);
GetVehicleZAngle(GetPlayerVehicleID(playerid), pos[3]);
if(CaravanInfo[playerid][cModel] == 3172)
{
pos[1]=pos[1]-8.7;
pos[2]=pos[2]-0.8;
}
else if(CaravanInfo[playerid][cModel] == 3171)
{
pos[1]=pos[1]-7.2;
pos[2]=pos[2]-0.8;
}
CaravanInfo[playerid][cXpos] = pos[0];
CaravanInfo[playerid][cYpos] = pos[1];
CaravanInfo[playerid][cZpos] = pos[2];
CaravanInfo[playerid][cRotation] = -pos[3];
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,\"data\");
INI_WriteInt(File,\"Model\", CaravanInfo[playerid][cModel]);
INI_WriteFloat(File,\"Xpos\",pos[0]);
INI_WriteFloat(File,\"Ypos\", pos[1]);
INI_WriteFloat(File,\"Zpos\", pos[2]);
INI_WriteFloat(File,\"Rotation\", CaravanInfo[playerid][cRotation]);
INI_WriteString(File,\"Owner\", CaravanInfo[playerid][cOwner]);
INI_WriteInt(File,\"Amount\", CaravanInfo[playerid][cAmount]);
INI_Close(File);
INI_Close(File);
DestroyObject(Caravan[playerid]);
Caravan[playerid] = CreateObject(
CaravanInfo[playerid][cModel],
pos[0],
pos[1],
pos[2],
0.0,
0.0,
CaravanInfo[playerid][cRotation],
0.0
);
return 1;
}
else if(strcmp(\"/buy\", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, DEALER_XPOS, DEALER_YPOS, DEALER_ZPOS))
{
if(fexist(UserPath(playerid)))
{
SendClientMessage(playerid, COLOR_RED, \"Neked már van karavánod! Használd /sellcaravan hogy eladd.\");
}
else
{
ShowPlayerDialog(playerid, DIALOG_BUYC, DIALOG_STYLE_LIST, \"Caravan Dealer\", \"Kicsi Caravan\\n Nagy Caravan\", \"Choose\", \"Cancel\");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, \"Nem vagy a caraván eladónál!\");
}
return 1;
}
else if(strcmp(\"/sellcaravan\", cmdtext, true, 10) == 0)
{
if(fexist(UserPath(playerid)))
{
DestroyObject(Caravan[playerid]);
fremove(UserPath(playerid));
}
else
{
SendClientMessage(playerid,COLOR_RED, \"Nincs Karavánod hogy eladd!\");
}
return 1;
}
return 0;
}
//=============================================================================
public LoadCaravans_data(playerid, name[], value[])
{
INI_Int(\"Model\",CaravanInfo[playerid][cModel]);
INI_Float(\"Xpos\",CaravanInfo[playerid][cXpos]);
INI_Float(\"Ypos\",CaravanInfo[playerid][cYpos]);
INI_Float(\"Zpos\",CaravanInfo[playerid][cZpos]);
INI_Float(\"Rotation\",CaravanInfo[playerid][cRotation]);
INI_String(\"Owner\",CaravanInfo[playerid][cOwner], 64);
INI_Int(\"Amount\",CaravanInfo[playerid][cAmount]);
Caravan[playerid] = CreateObject(
CaravanInfo[playerid][cModel],
CaravanInfo[playerid][cXpos],
CaravanInfo[playerid][cYpos],
CaravanInfo[playerid][cZpos],
0.0,
0.0,
CaravanInfo[playerid][cRotation],
0.0
);
return 1;
}
//=============================================================================
stock LoadCaravan(playerid)
{
Caravan[playerid] = CreateObject(
CaravanInfo[playerid][cModel],
CaravanInfo[playerid][cXpos],
CaravanInfo[playerid][cYpos],
CaravanInfo[playerid][cZpos],
0.0,
0.0,
CaravanInfo[playerid][cRotation],
0.0
);
return 1;
}
//=============================================================================
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
//=============================================================================
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 70:
{
ShowPlayerDialog(playerid, DIALOG_CONFIRMC, DIALOG_STYLE_MSGBOX, \"Confirm Deal\", \"Are you sure, you want to buy this caravan?\", \"Confirm\", \"Cancel\");
if(listitem == 0)
{
CaravanChoise[playerid] = 0;
}
else if(listitem == 1)
{
CaravanChoise[playerid] = 1;
}
}
case 71:
{
switch(response)
{
case 1:
{
if(CaravanChoise[playerid] == 0)
{
if(GetPlayerMoney(playerid) > SMALL_CARAVAN_PRICE)
{
GivePlayerMoney(playerid, -SMALL_CARAVAN_PRICE);
new playername[64];
GetPlayerName(playerid, playername, sizeof playername);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,\"data\");
INI_WriteInt(File,\"Model\", 3171);
INI_WriteFloat(File,\"Xpos\",DEALER_XPOS);
INI_WriteFloat(File,\"Ypos\",DEALER_YPOS);
INI_WriteFloat(File,\"Zpos\", DEALER_ZPOS);
INI_WriteFloat(File,\"Rotation\",180.0000);
INI_WriteString(File,\"Owner\", playername);
INI_WriteInt(File,\"Amount\", 1);
INI_Close(File);
INI_ParseFile(UserPath(playerid), \"LoadCaravans_%s\", .bExtra = true, .extra = playerid);
LoadCaravan(playerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, \"Nincs elég pénzed ehhez a karavánhoz!\");
}
}
else if(CaravanChoise[playerid] == 1)
{
if(GetPlayerMoney(playerid) > BIG_CARAVAN_PRICE)
{
GivePlayerMoney(playerid, -BIG_CARAVAN_PRICE);
new playername[64];
GetPlayerName(playerid, playername, sizeof playername);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,\"data\");
INI_WriteInt(File,\"Model\", 3172);
INI_WriteFloat(File,\"Xpos\",DEALER_XPOS);
INI_WriteFloat(File,\"Ypos\",DEALER_YPOS);
INI_WriteFloat(File,\"Zpos\", DEALER_ZPOS);
INI_WriteFloat(File,\"Rotation\",180.0000);
INI_WriteString(File,\"Owner\", playername);
INI_WriteInt(File,\"Amount\", 1);
INI_Close(File);
INI_ParseFile(UserPath(playerid), \"LoadCaravans_%s\", .bExtra = true, .extra = playerid);
LoadCaravan(playerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, \"nincs elég pénzed ehhez a karavánhoz!\");
}
}
}
}
}
}
return 1;
}
//=============================================================================
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), \"LoadCaravans_%s\", .bExtra = true, .extra = playerid);
LoadCaravan(playerid);
}
return 1;
}
//=============================================================================
public OnPlayerDisconnect(playerid)
{
DestroyObject(Caravan[playerid]);
return 1;
}
//=============================================================================
// NOTE: BIG CARAVAN ID: 3172
// SMALL CARAVAN ID: 3171
//=============================================================================[/pawn]