Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- #include streamer
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
- #define function%0(%1) \
- forward%0(%1); public%0(%1)
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
- static const RENT_PRICE = 200;
- static const RENT_DESTROY = 120;
- static gRentMotoID[MAX_PLAYERS] = {INVALID_VEHICLE_ID, ...};
- static gRentMotoTimer[MAX_PLAYERS] = {-1, ...};
- static gRentMotoCount[MAX_PLAYERS];
- static Text3D:gRentMotoLabel[MAX_PLAYERS];
- static const Float:gRentMotoSpawns[][] =
- {
- {1098.5000, -1755.0000, 12.8220, 90.0000},
- {1098.5000, -1757.9000, 12.8220, 90.0000},
- {1098.5000, -1760.8500, 12.8220, 90.0000},
- {1098.5000, -1763.8500, 12.8220, 90.0000}
- };
- main(){}
- public OnGameModeInit()
- {
- AddPlayerClass(0, 1144.3022, -1761.5577, 13.2000, 0.0000, 0, 0, 0, 0, 0, 0);
- CreateDynamicPickup(1318, 1, 1139.4188, -1761.8510, 13.5955, .streamdistance = 50.0);
- CreateDynamic3DTextLabel("Motos\nPressione F ou Enter", -1, 1139.4188, -1761.8510, 13.5955+0.75, 25.0, .testlos = 1);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- return GivePlayerMoney(playerid, 10000);
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(PRESSED(KEY_SECONDARY_ATTACK))
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, 1139.4188, -1761.8510, 13.5955))
- {
- if(IsPlayerInAnyVehicle(playerid))
- return SendClientMessage(playerid, -1, "* Você está conduzindo um veículo.");
- if(gRentMotoID[playerid] != INVALID_VEHICLE_ID)
- return SendClientMessage(playerid, -1, "* Você não pode pegar uma moto com outra criada.");
- if(GetPlayerMoney(playerid) < RENT_PRICE)
- return SendClientMessage(playerid, -1, "* Você não tem dinheiro suficiente.");
- new rand = random(sizeof(gRentMotoSpawns));
- gRentMotoID[playerid] = CreateVehicle(581, gRentMotoSpawns[rand][0], gRentMotoSpawns[rand][1], gRentMotoSpawns[rand][2], gRentMotoSpawns[rand][3], -1, -1, -1);
- PutPlayerInVehicle(playerid, gRentMotoID[playerid], 0);
- GivePlayerMoney(playerid, -RENT_PRICE);
- }
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- switch(newstate)
- {
- case PLAYER_STATE_DRIVER:
- {
- if(gRentMotoID[playerid] != INVALID_VEHICLE_ID && gRentMotoCount[playerid] != 0 && gRentMotoTimer[playerid] != -1)
- {
- DestroyDynamic3DTextLabel(gRentMotoLabel[playerid]);
- KillTimer(gRentMotoTimer[playerid]);
- gRentMotoTimer[playerid] = -1;
- gRentMotoCount[playerid] = 0;
- }
- }
- }
- switch(oldstate)
- {
- case PLAYER_STATE_DRIVER:
- {
- if(gRentMotoID[playerid] != INVALID_VEHICLE_ID && !gRentMotoCount[playerid] && gRentMotoTimer[playerid] == -1)
- {
- if(IsValidDynamic3DTextLabel(gRentMotoLabel[playerid]))
- DestroyDynamic3DTextLabel(gRentMotoLabel[playerid]);
- gRentMotoCount[playerid] = RENT_DESTROY;
- gRentMotoTimer[playerid] = SetTimerEx("OnDestroyRentMotoUpdate", 1000, true, "i", playerid);
- gRentMotoLabel[playerid] = CreateDynamic3DTextLabel("{FF0000}Moto destruída em:\n{FFFFFF}00:00", -1, 0.0, 0.0, 0.0, 50.0, .attachedvehicle = gRentMotoID[playerid]);
- }
- }
- }
- return 1;
- }
- function OnDestroyRentMotoUpdate(playerid)
- {
- if(gRentMotoTimer[playerid] != -1)
- {
- if((--gRentMotoCount[playerid]) < 0)
- {
- DestroyDynamic3DTextLabel(gRentMotoLabel[playerid]);
- DestroyVehicle(gRentMotoID[playerid]);
- KillTimer(gRentMotoTimer[playerid]);
- gRentMotoTimer[playerid] = -1;
- gRentMotoCount[playerid] = 0;
- gRentMotoID[playerid] = INVALID_VEHICLE_ID;
- SendClientMessage(playerid, -1, "* Você demorou muito para voltar à moto e ela foi destruída.");
- }
- else
- {
- new label[45];
- format(label, sizeof(label), "{FF0000}Moto destruída em:\n{FFFFFF}%02d:%02d", gRentMotoCount[playerid] / 60, gRentMotoCount[playerid] % 60);
- UpdateDynamic3DTextLabelText(gRentMotoLabel[playerid], -1, label);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement