Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- //============//
- new bool:CSpike1[MAX_PLAYERS];
- new bool:CSpike2[MAX_PLAYERS];
- new Spike1[MAX_PLAYERS];
- new Spike2[MAX_PLAYERS];
- //============//
- #define COLOR_RED 0xFF0000AA
- new Float:spX, Float:spY, Float:spZ, Float:spA;
- stock PopPlayerTires(playerid)
- {
- new vehicleid = GetPlayerVehicleID(playerid);
- new panels, doors, lights, tires;
- GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
- tires = encode_tires(1, 1, 1, 1);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, 15);
- }
- ///////////////////////////////////////////////////////
- CMD:cspike(playerid, params[])
- {
- new id;
- GetPlayerPos(playerid, spX, spY, spZ);
- GetPlayerFacingAngle(playerid, spA);
- if(sscanf(params, "i", id))
- {
- SendClientMessage(playerid, 0xFF0000AA, "/cspike [1|2]");
- SendClientMessage(playerid, -1, "1 - Small");
- SendClientMessage(playerid, -1, "2 - Big");
- return 1;
- }
- if(id == 1)
- {
- if(CSpike1[playerid] == false && CSpike2[playerid] == false)
- {
- Spike1[playerid] = CreateObject(2899, spX+5, spY, spZ-0.83, 0.0, 0.0, spA+180);
- CSpike1[playerid] = true;
- SendClientMessage(playerid, -1, "You set a Small spike.");
- }
- else return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: You already have created Spike!.");
- }
- else if(id == 2)
- {
- if(CSpike2[playerid] == false && CSpike1[playerid] == false)
- {
- Spike2[playerid] = CreateObject(2892, spX+5, spY, spZ-0.95, 0.0, 0.0, spA+180);
- CSpike2[playerid] = true;
- SendClientMessage(playerid, -1, "You set a Big spike.");
- }
- else return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: You already have created Spike.");
- }
- else return SendClientMessage(playerid, 0xFF0000AA, "Wrong spike id [1|2].");
- return 1;
- }
- /////////////////////////////////////////////////////////////////////////////
- CMD:destroyspike(playerid, params[])
- {
- new id;
- if(sscanf(params, "i", id)) return SendClientMessage(playerid,-1, "/dspike [1|2]");
- if(id == 1)
- {
- if(CSpike1[playerid] == true)
- {
- DestroyObject(Spike1[playerid]);
- SendClientMessage(playerid, -1, "Small spike destroyed.");
- CSpike1[playerid] = false;
- }
- else return SendClientMessage(playerid, -1, "Small spike is not created.");
- }
- else if(id == 2)
- {
- if(CSpike2[playerid] == true)
- {
- DestroyObject(Spike2[playerid]);
- SendClientMessage(playerid, -1, "Bug spike destroyed.");
- CSpike2[playerid] = false;
- }
- else return SendClientMessage(playerid, -1, "Big spike is not created.");
- }
- else return SendClientMessage(playerid, 0xFF0000AA, "Wrong spike id [1|2].");
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, spX+5, spY, spZ-0.83))
- {
- if(CSpike1[playerid] == 1)
- {
- PopPlayerTires(playerid);
- }
- }
- }
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, spX+5, spY, spZ-0.95))
- {
- if(CSpike2[playerid] == 1)
- {
- PopPlayerTires(playerid);
- }
- }
- }
- return 1;
- }
- //============================================================================//
- encode_tires(tires1, tires2, tires3, tires4) {
- return tires1 | (tires2 << 1) | (tires3 << 2) | (tires4 << 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement