Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- #include zcmd
- new bool: DrivingPumpkin[MAX_PLAYERS];
- new Pumpkin[MAX_PLAYERS] = INVALID_OBJECT_ID;
- new bool: AdminOnly = false;
- #define PUMPKIN_SPEED 5.0
- CMD:togadminonly(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- if(AdminOnly == true)
- {
- AdminOnly = false;
- SendClientMessage(playerid, -1, "You have unrestricted the pumpkin system.");
- return true;
- }
- else
- {
- AdminOnly = true;
- SendClientMessage(playerid, -1, "You have restricted the pumpkin system to administrators.");
- return true;
- }
- }
- return true;
- }
- CMD:createpumpkin(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid) && AdminOnly == true)
- {
- SendClientMessage(playerid, -1, "This command has been restricted to administrators.");
- return true;
- }
- if(DrivingPumpkin[playerid])
- {
- return SendClientMessage(playerid, -1, "You're already driving a pumpkin. Use /destroypumpkin to stop driving.");
- }
- ApplyAnimation(playerid, "FOOD", "FF_Sit_Eat2", 4.0, 1, 0, 0, 1, 0, 1);
- new Float: X, Float: Y, Float: Z;
- GetPlayerPos(playerid, X, Y, Z);
- Pumpkin[playerid] = CreateObject(19320, X, Y, Z, 0.0, 0.0, 0.0);
- DrivingPumpkin[playerid] = true;
- TogglePlayerControllable(playerid, false); // - Manually controlled movements.
- return 1;
- }
- CMD:destroypumpkin(playerid, params[])
- {
- if(DrivingPumpkin[playerid] == true)
- {
- DestroyObject(Pumpkin[playerid]);
- DrivingPumpkin[playerid] = false;
- Pumpkin[playerid] = INVALID_OBJECT_ID;
- TogglePlayerControllable(playerid, true);
- SetCameraBehindPlayer(playerid);
- return true;
- }
- }
- CMD:pumpkin(playerid, params[])
- {
- if(isnull(params)) return true;
- if(DrivingPumpkin[playerid] == false) return SendClientMessage(playerid, -1, "You're not driving a pumpkin.");
- if(strcmp(params, "up", true) == 0)
- {
- new Float: pos[3];
- GetObjectPos(Pumpkin[playerid], pos[0], pos[1], pos[2]);
- SetObjectPos(Pumpkin[playerid], pos[0], pos[1], pos[2]+1.0);
- }
- if(strcmp(params, "down", true) == 0)
- {
- new Float: pos[3];
- GetObjectPos(Pumpkin[playerid], pos[0], pos[1], pos[2]);
- SetObjectPos(Pumpkin[playerid], pos[0], pos[1], pos[2]-1.0);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- for (new i = 0; i != MAX_PLAYERS; ++i)
- {
- if (IsPlayerConnected(i))
- {
- if(DrivingPumpkin[i] == true)
- {
- DrivingPumpkin[i] = false;
- DestroyObject(Pumpkin[i]);
- Pumpkin[i] = -1;
- }
- }
- }
- }
- public OnPlayerDisconnect(playerid)
- {
- if(DrivingPumpkin[playerid] == true)
- {
- DrivingPumpkin[playerid] = false;
- DestroyObject(Pumpkin[playerid]);
- Pumpkin[playerid] = -1;
- }
- return true;
- }
- public OnPlayerUpdate(playerid)
- {
- if(DrivingPumpkin[playerid] == true)
- {
- new Keys,ud,lr;
- GetPlayerKeys(playerid,Keys,ud,lr);
- new objectid = Pumpkin[playerid];
- new Float: pos[3];
- GetObjectPos(objectid, pos[0], pos[1], pos[2]);
- SetPlayerPos(playerid, pos[0], pos[1], pos[2]+0.5);
- if(ud == KEY_UP)
- {
- new Float: X, Float: Y, Float: Z;
- GetObjectPos(objectid, X, Y, Z);
- MoveObject(objectid, X, Y+2.0, Z, PUMPKIN_SPEED, 0.0, 0.0, 0.0);
- return true;
- }
- else if(ud == KEY_DOWN)
- {
- new Float: X, Float: Y, Float: Z;
- GetObjectPos(objectid, X, Y, Z);
- MoveObject(objectid, X, Y-2.0, Z, PUMPKIN_SPEED, 0.0, 0.0, 0.0);
- return true;
- }
- if(lr == KEY_LEFT)
- {
- new Float: X, Float: Y, Float: Z;
- GetObjectPos(objectid, X, Y, Z);
- MoveObject(objectid, X-2.0, Y, Z, PUMPKIN_SPEED, 0.0, 0.0, 0.0);
- return true;
- }
- else if(lr == KEY_RIGHT)
- {
- new Float: X, Float: Y, Float: Z;
- GetObjectPos(objectid, X, Y, Z);
- MoveObject(objectid, X+2.0, Y, Z, PUMPKIN_SPEED, 0.0, 0.0, 0.0);
- return true;
- }
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(DrivingPumpkin[playerid] == true)
- {
- DestroyObject(Pumpkin[playerid]);
- Pumpkin[playerid] = -1;
- DrivingPumpkin[playerid] = false;
- return 1;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement