Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <color>
- #include <streamer>
- #define MAX_ROADBLOCKS 25
- enum rInfo
- {
- sCreated,
- Float:sX,
- Float:sY,
- Float:sZ,
- sObject,
- copid,
- Text3D:rbLabel
- };
- new Roadblocks[MAX_ROADBLOCKS][rInfo];
- COMMAND:rarb(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- for(new i = 0; i < sizeof(Roadblocks); i++)
- {
- Roadblocks[i][sCreated] = 0;
- Roadblocks[i][sX] = 0.0;
- Roadblocks[i][sY] = 0.0;
- Roadblocks[i][sZ] = 0.0;
- DestroyDynamicObject(Roadblocks[i][sObject]);
- Delete3DTextLabel(Roadblocks[i][rbLabel]);
- }
- SendClientMessageToAll(-1, "{FFFFFF}An administrator has removed all road blocks.");
- }
- return 1;
- }
- COMMAND:placerb(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- if (GetPlayerInterior(playerid) > 0)
- {
- new Float:plocx, Float:plocy, Float:plocz, Float:ploca;
- GetPlayerPos(playerid, plocx, plocy, plocz);
- GetPlayerFacingAngle(playerid, ploca);
- CreateRoadblock(978, plocx, plocy, plocz + 0.6, ploca, playerid);
- }
- else
- {
- Server(playerid, "Road blocks can only be placed out doors.");
- }
- }
- else
- {
- Server(playerid, "This command can only be used by admin");
- }
- return 1;
- }
- COMMAND:delrb(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- DeleteClosestRoadblock(playerid);
- }
- else
- {
- Server(playerid, "This command can only be used by admin");
- }
- return 1;
- }
- stock CreateRoadblock(Object,Float:x,Float:y,Float:z,Float:Angle, playerid)
- {
- new count = 0;
- for(new i = 0; i < sizeof(Roadblocks); i++)
- {
- if(Roadblocks[i][sCreated] == 0)
- {
- new creatorString[200];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- Roadblocks[i][sCreated] = 1;
- Roadblocks[i][sX] = x;
- Roadblocks[i][sY] = y;
- Roadblocks[i][sZ] = z - 0.7;
- Roadblocks[i][copid] = playerid;
- Roadblocks[i][sObject] = CreateDynamicObject(Object, x, y, z - 0.9, 0, 0, Angle);
- format(creatorString, sizeof(creatorString), CHAT_RED"[ROADBLOCK]"CHAT_WHITE"Placed By: "CHAT_RED"%s", name);
- Roadblocks[i][rbLabel] = Create3DTextLabel(creatorString, 0xFF0000FF, x, y, z, 25.0, 0);
- Server(playerid, "You placed a roadblock. To remove it, type "CHAT_YELLOW"/delrb"CHAT_WHITE" while standing near it.");
- count++;
- return 1;
- }
- }
- if (!count)
- {
- Server(playerid, "Maximum number of roadblocks created. ask an admin to remove some.");
- }
- return 0;
- }
- stock DeleteAllRoadblocks(playerid)
- {
- for(new i = 0; i < sizeof(Roadblocks); i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 100, Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
- {
- if(Roadblocks[i][sCreated] == 1)
- {
- Roadblocks[i][sCreated] = 0;
- Roadblocks[i][sX] = 0.0;
- Roadblocks[i][sY] = 0.0;
- Roadblocks[i][sZ] = 0.0;
- DestroyDynamicObject(Roadblocks[i][sObject]);
- Delete3DTextLabel(Roadblocks[i][rbLabel]);
- }
- }
- }
- return 0;
- }
- stock DeleteClosestRoadblock(playerid)
- {
- for(new i = 0; i < sizeof(Roadblocks); i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 5.0, Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
- {
- if(Roadblocks[i][sCreated] == 1)
- {
- Roadblocks[i][sCreated] = 0;
- Roadblocks[i][sX] = 0.0;
- Roadblocks[i][sY] = 0.0;
- Roadblocks[i][sZ] = 0.0;
- DestroyDynamicObject(Roadblocks[i][sObject]);
- Delete3DTextLabel(Roadblocks[i][rbLabel]);
- Server(playerid, "Succesfully removed a roadblock.");
- return 1;
- }
- }
- }
- return 0;
- }
- stock removePlayerRoadblocks(playerid)
- {
- for(new i = 0; i < sizeof(Roadblocks); i++)
- {
- if(Roadblocks[i][copid] == playerid)
- {
- Roadblocks[i][sCreated] = 0;
- Roadblocks[i][sX] = 0.0;
- Roadblocks[i][sY] = 0.0;
- Roadblocks[i][sZ] = 0.0;
- DestroyDynamicObject(Roadblocks[i][sObject]);
- Delete3DTextLabel(Roadblocks[i][rbLabel]);
- return 1;
- }
- else
- {
- continue;
- }
- }
- return 0;
- }
- stock Server(playerid, message[])
- {
- new smg[144];
- format(smg, sizeof(smg), ""COLOR_LAWNGREEN"[SERVER]"COLOR_WHITE" %s", message);
- SendClientMessage(playerid, -1, smg);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement