Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Biblioteki:
- #include <a_samp>
- #include <YSF>
- #include <YSI\y_iterate>
- #include <zcmd>
- // Makra i constansy:
- #define function%0(%1) forward%0(%1); public%0(%1)
- #define BindKey(%1) if(newkeys & BindKey_(%1))
- // Zmienne:
- new
- bool:UpdateSpeed[MAX_PLAYERS] = {false, ...},
- PlayerText3D: Speed3DText[MAX_PLAYERS],
- Text: km[MAX_PLAYERS],
- VehicleCmdNames[212][32] = {
- "/Landstalker", "/Bravura", "/Buffalo", "/Linerunner", "/Pereniel", "/Sentinel", "/Dumper", "/Firetruck", "/Trashmaster", "/Stretch",
- "/Manana", "/Infernus", "/Voodoo", "/Pony", "/Mule", "/Cheetah", "/Ambulance", "/Leviathan", "/Moonbeam", "/Esperanto",
- "/Taxi", "/Washington", "/Bobcat", "/Mr Whoopee", "/BF Injection", "/Hunter", "/Premier", "/Enforcer", "/Securicar", "/Banshee",
- "/Predator", "/Bus", "/Rhino", "/Barracks", "/Hotknife", "/Trailer", "/Previon", "/Coach", "/Cabbie", "/Stallion",
- "/Rumpo", "/RC Bandit", "/Romero", "/Packer", "/Monster", "/Admiral", "/Squalo", "/Seasparrow", "/Pizzaboy", "/Tram",
- "/Trailer", "/Turismo", "/Speeder", "/Reefer", "/Tropic", "/Flatbed", "/Yankee", "/Caddy", "/Solair", "/Berkley's RC Van",
- "/Skimmer", "/PCJ-600", "/Faggio", "/Freeway", "/RC Baron", "/RC Raider", "/Glendale", "/Oceanic", "/Sanchez", "/Sparrow",
- "/Patriot", "/Quad", "/Coastguard", "/Dinghy", "/Hermes", "/Sabre", "/Rustler", "/ZR 350", "/Walton", "/Regina",
- "/Comet", "/BMX", "/Burrito", "/Camper", "/Marquis", "/Baggage", "/Dozer", "/Maverick", "/News Chopper", "/Rancher",
- "/FBI Rancher", "/Virgo", "/Greenwood", "/Jetmax", "/Hotring", "/Sandking", "/Blista Compact", "/Police Maverick", "/Boxville", "/Benson",
- "/Mesa", "/RC Goblin", "/Hotring Racer", "/Hotring Racer", "/Bloodring Banger", "/Rancher", "/Super GT", "/Elegant", "/Journey", "/Bike",
- "/Mountain Bike", "/Beagle", "/Cropdust", "/Stunt", "/Tanker", "/RoadTrain", "/Nebula", "/Majestic", "/Buccaneer", "/Shamal",
- "/Hydra", "/FCR", "/NRG", "/HPV1000", "/Cement Truck", "/Tow Truck", "/Fortune", "/Cadrona", "/FBI Truck", "/Willard",
- "/Forklift", "/Tractor", "/Combine", "/Feltzer", "/Remington", "/Slamvan", "/Blade", "/Freight", "/Streak", "/Vortex",
- "/Vincent", "/Bullet", "/Clover", "/Sadler", "/Firetruck", "/Hustler", "/Intruder", "/Primo", "/Cargobob", "/Tampa",
- "/Sunrise", "/Merit", "/Utility", "/Nevada", "/Yosemite", "/Windsor", "/Monstera", "/Monsterb", "/Uranus", "/Jester",
- "/Sultan", "/Stratum", "/Elegy", "/Raindance", "/RC Tiger", "/Flash", "/Tahoma", "/Savanna", "/Bandito", "/Freight",
- "/Trailer", "/Kart", "/Mower", "/Duneride", "/Sweeper", "/Broadway", "/Tornado", "/AT-400", "/DFT-30", "/Huntley",
- "/Stafford", "/BF-400", "/Newsvan", "/Tug", "/Trailer2", "/Emperor", "/Wayfarer", "/Euros", "/Hotdog", "/Club",
- "/Trailer3", "/Trailer4", "/Andromeda", "/Dodo", "/RC Cam", "/Launch", "/Police Car (LSPD)", "/Police Car (SFPD)", "/Police Car (LVPD)", "/Police Ranger",
- "/Picador", "/S.W.A.T. Van", "/Alpha", "/Phoenix", "/Glendale", "/Sadler", "/Luggage Trailer", "/Luggage Trailer2", "/Stair Trailer", "/Boxville",
- "/Farm Plow", "/Utility Trailer"
- }
- ;
- // Funkcje statyczne:
- stock BindKey_(key[]) {
- if(!strcmp("action", key, true)) return KEY_ACTION;
- else if(!strcmp("crouch", key, true)) return KEY_CROUCH;
- else if(!strcmp("fire", key, true)) return KEY_FIRE;
- else if(!strcmp("sprint", key, true)) return KEY_SPRINT;
- else if(!strcmp("attack", key, true)) return KEY_SECONDARY_ATTACK;
- else if(!strcmp("jump", key, true)) return KEY_JUMP;
- else if(!strcmp("lookr", key, true)) return KEY_LOOK_RIGHT;
- else if(!strcmp("lookl", key, true)) return KEY_LOOK_LEFT;
- else if(!strcmp("lookb", key, true)) return KEY_LOOK_BEHIND;
- else if(!strcmp("handbrake", key, true)) return KEY_HANDBRAKE;
- else if(!strcmp("submission", key, true)) return KEY_SUBMISSION;
- else if(!strcmp("walk", key, true)) return KEY_WALK;
- else if(!strcmp("aup", key, true)) return KEY_ANALOG_UP;
- else if(!strcmp("adown", key, true)) return KEY_ANALOG_DOWN;
- else if(!strcmp("aleft", key, true)) return KEY_ANALOG_LEFT;
- else if(!strcmp("aright", key, true)) return KEY_ANALOG_RIGHT;
- else if(!strcmp("yes", key, true)) return KEY_YES;
- else if(!strcmp("no", key, true)) return KEY_NO;
- else if(!strcmp("ctrlback", key, true)) return KEY_NO;
- else if(!strcmp("up", key, true)) return KEY_UP;
- else if(!strcmp("down", key, true)) return KEY_DOWN;
- else if(!strcmp("left", key, true)) return KEY_LEFT;
- else if(!strcmp("right", key, true)) return KEY_RIGHT;
- else return false;
- }
- stock rand(one, two) {
- return random(two - one) + one;
- }
- stock GetPlayerSpeed(v) {
- new Float: X, Float: Y, Float: Z;
- GetVehicleVelocity(v, X, Y, Z);
- return floatround(floatsqroot(floatpower(X, 2) + floatpower(Y, 2) + floatpower(Z, 2)) * 190);
- }
- stock CreateVehicleEx(playerid, vehiclemodel, color1, color2) {
- new Float: x, Float: y, Float: z;
- new Float: facing;
- new Float: distance;
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, facing);
- new Float: size_x, Float: size_y, Float: size_z;
- GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
- distance = size_x + 0.5;
- x += (distance * floatsin(- facing, degrees));
- y += (distance * floatcos(- facing, degrees));
- facing += 90.0;
- if(facing > 360.0) facing -= 360.0;
- return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
- }
- stock GetVehicleName(vehicleid) {
- static String[30];
- format(String,sizeof(String),"%s",VehicleCmdNames[GetVehicleModel(vehicleid) - 400][1]);
- return String;
- }
- // Funkcje publiczne:
- main();
- public OnGameModeInit() {
- new i = 0;
- while(i++ <= 299) {
- AddPlayerClass(i, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
- }
- SetModeRestartTime(0.1);
- printf("Random między liczbami %d a %d to: %d", 5, 10, rand(5, 10));
- return true;
- }
- public OnPlayerConnect(playerid) {
- UpdateSpeed[playerid] = false;
- return true;
- }
- public OnPlayerDisconnect(playerid, reason) {
- if(!IsPlayerConnected(playerid)) return DeletePlayer3DTextLabel(playerid, Speed3DText[playerid]);
- return true;
- }
- public OnPlayerUpdate(playerid) {
- if(UpdateSpeed[playerid]) {
- new str[MAX_PLAYERS][128];
- format(str[playerid], sizeof(str), "[%s]\n%d km/h", GetVehicleName(GetPlayerVehicleID(playerid)), GetPlayerSpeed(GetPlayerVehicleID(playerid)));
- UpdatePlayer3DTextLabelText(playerid, Speed3DText[playerid], -1, str[playerid]);
- }
- }
- public OnPlayerStateChange(playerid, newstate, oldstate) {
- switch(newstate) {case PLAYER_STATE_DRIVER: {
- Speed3DText[playerid] = CreatePlayer3DTextLabel(playerid, "Infernus\n666 KM/H", -1, 0, 0, 0, 15.0, INVALID_PLAYER_ID, GetPlayerVehicleID(playerid), 1);
- UpdateSpeed[playerid] = true;
- }}
- switch(oldstate) {case PLAYER_STATE_DRIVER: {
- DeletePlayer3DTextLabel(playerid, Speed3DText[playerid]);
- UpdateSpeed[playerid] = false;
- }}
- return true;
- }
- public OnPlayerCommandReceived(playerid, cmdtext[]) {
- new
- vid[MAX_PLAYERS],
- string[MAX_PLAYERS][64],
- i = 0;
- while(i++ < sizeof(VehicleCmdNames)) {
- if(strfind(VehicleCmdNames[i], cmdtext, true) != -1) {
- if(!IsPlayerAdmin(playerid)) {
- switch(i + 400) {case 425, 432, 441, 406, 449, 464, 465, 501, 520, 537, 538, 564, 569, 570, 590, 591, 594, 606 .. 608, 610, 611: return SendClientMessage(playerid, -1, "Tego pojazdu nie możesz stworzyć nie będąc administratorem!");}
- }
- vid[playerid] = CreateVehicleEx(playerid, i + 400, -1, -1);
- LinkVehicleToInterior(vid[playerid], GetPlayerInterior(playerid));
- SetVehicleVirtualWorld(vid[playerid], GetPlayerVirtualWorld(playerid));
- format(string[playerid], sizeof(string), "Tworzysz %s", VehicleCmdNames[i]);
- printf(string[playerid]);
- PutPlayerInVehicle(playerid, vid[playerid], 0);
- return false;
- }
- }
- return true;
- }
- public OnGameModeExit() {
- new i = 0;
- while(i++ < MAX_PLAYERS) {
- TextDrawDestroy(km[i]);
- }
- return true;
- }
- public OnPlayerSpawn(playerid) {
- SetPlayerPos(playerid, 0.0, 0.0, 0.0);
- SetPlayerWorldBounds(playerid, 20000.0, -20000.0, 20000.0, -20000.0);
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
- BindKey("submission") {
- RepairVehicle(GetPlayerVehicleID(playerid));
- GameTextForPlayer(playerid,"~y~Pojazd naprawiony!",2000,5);
- PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement