Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <streamer>
- #include <YSI\y_iterate>
- #include <YSI\y_timers>
- #define MAX_POS_COMMANS 2048
- #define BOJA_POS_CMD "{00FF00}"
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- new Iterator:PosComand<MAX_POS_COMMANS>;
- enum pcI {
- Text3D:_label,
- _pickup,
- _id,
- bool:_mozeizvozila,
- bool:_postavljena,
- Float:_XX,
- Float:_YY,
- Float:_ZZ
- };
- new PC[MAX_POS_COMMANS][pcI];
- #if defined FILTERSCRIPT
- hook OnFilterScriptExit()
- #else
- hook OnGameModeExit()
- #endif
- {
- foreach(new i: PosComand) {
- DestroyPosCommand(i);
- }
- return 1;
- }
- hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(PRESSED(KEY_YES) && !GetPVarInt(playerid, "PCmdOdario")) {
- foreach(new i: PosComand) {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, PC[i][_XX], PC[i][_YY], PC[i][_ZZ])) {
- if(IsPlayerInAnyVehicle(playerid) && PC[i][_mozeizvozila] == false) return 1;
- else {
- OnPosCommandPreesed(playerid, PC[i][_id]);
- SetPVarInt(playerid, "PCmdOdario", 1);
- defer SkiniPCmdOdradio(playerid);
- return 1;
- }
- }
- }
- }
- return 1;
- }
- timer SkiniPCmdOdradio[2000](playerid) return DeletePVar(playerid, "PCmdOdario");
- stock CreatePosCommand(poscmdID, const PCText[], Float:pcX, Float:pcY, Float:pcZ, bool:MozeIzVozila = true, pickupTip = 1239) {
- if(poscmdID >= MAX_POS_COMMANS-1) {
- if(poscmdID == MAX_POS_COMMANS-1) print("ERROR: Dostigli ste maximalan broj PosComand. Povecajte 'MAX_POS_COMMANS'.");
- return 1;
- }
- if(PC[poscmdID][_postavljena] == true) {
- printf("ERROR: Pokusali ste kreirati PocComand ID: %d, ona vec postoji.", poscmdID);
- return 1;
- }
- new pcString[256];
- strcat(pcString, PCText, sizeof(pcString));
- strcat(pcString, "\n"BOJA_POS_CMD"Pritisnite tipku 'Y'", sizeof(pcString));
- PC[poscmdID][_label] = CreateDynamic3DTextLabel(pcString, 0xFFFFFFCC, pcX, pcY, pcZ, 20.0);
- PC[poscmdID][_pickup] = CreateDynamicPickup(pickupTip, 1, pcX, pcY, pcZ);
- PC[poscmdID][_id] = poscmdID;
- PC[poscmdID][_mozeizvozila] = MozeIzVozila;
- PC[poscmdID][_postavljena] = true;
- PC[poscmdID][_XX] = pcX;
- PC[poscmdID][_YY] = pcY;
- PC[poscmdID][_ZZ] = pcZ;
- Iter_Add(PosComand, poscmdID);
- return 1;
- }
- stock DestroyPosCommand(poscmdID) {
- if(PC[poscmdID][_postavljena] == false) return 1;
- DestroyDynamic3DTextLabel(PC[poscmdID][_label]);
- DestroyDynamicPickup(PC[poscmdID][_pickup]);
- PC[poscmdID][_postavljena] = false;
- Iter_Remove(PosComand, poscmdID);
- return 1;
- }
- forward OnPosCommandPreesed(playerid, pcid);
Advertisement
Add Comment
Please, Sign In to add comment