Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ________________________________
- __,__ ( )
- .--. .-" "-. .--. (wow! pspec system i wanted that )
- / .. \/ .-. .-. \/ .. \ ( only !!! )
- | | '| / Y \ |' | | / ( please dont remove the credits)
- | \ \ \ 0 | 0 / / / | / ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
- \ '- ,\.-"`` ``"-./, -' / /
- `'-' /_ ^ ^ _\ '-'` /
- .--'| \._ _ _./ |'--.
- /` \ \.-. / / `\
- / '._/ |-' _.' \
- / ; /--~' | \
- / .'\|.-\--. \ \
- / .'-. /.-.;\ |\|'~'-.|\ \
- \ `-./`|_\_/ ` `\'. \
- '. ; ___) '.`; /
- '-.,_ ; ___) \/ /
- \ ``'------'\ \ ` /
- '. \ '. | ;/_
- ___> '. \_ _ _/ , '--.
- .' '. .-~~~~~-. / |--'`~~-. \
- // / .---'/ .-~~-._/ / / /---..__.' /
- ((_(_/ / / (_(_(_(---.__ .'
- | | _ `~~`
- | | \'.
- \ '....' |
- '.,___.'
- #Name: pspec system
- #Author: CandyBoy
- #Release: 29/12/12
- */
- #include <a_samp>
- new Float:coords[MAX_PLAYERS][3], Spectating[MAX_PLAYERS];
- new Interior[MAX_PLAYERS];
- new aWeaponNames[][32] = {
- {"Unarmed (Fist)"}, // 0
- {"Brass Knuckles"}, // 1
- {"Golf Club"}, // 2
- {"Night Stick"}, // 3
- {"Knife"}, // 4
- {"Baseball Bat"}, // 5
- {"Shovel"}, // 6
- {"Pool Cue"}, // 7
- {"Katana"}, // 8
- {"Chainsaw"}, // 9
- {"Purple Dildo"}, // 10
- {"Big White Vibrator"}, // 11
- {"Medium White Vibrator"}, // 12
- {"Small White Vibrator"}, // 13
- {"Flowers"}, // 14
- {"Cane"}, // 15
- {"Grenade"}, // 16
- {"Teargas"}, // 17
- {"Molotov"}, // 18
- {" "}, // 19
- {" "}, // 20
- {" "}, // 21
- {"Colt 45"}, // 22
- {"Colt 45 (Silenced)"}, // 23
- {"Desert Eagle"}, // 24
- {"Normal Shotgun"}, // 25
- {"Sawnoff Shotgun"}, // 26
- {"Combat Shotgun"}, // 27
- {"Micro Uzi (Mac 10)"}, // 28
- {"MP5"}, // 29
- {"AK47"}, // 30
- {"M4"}, // 31
- {"Tec9"}, // 32
- {"Country Rifle"}, // 33
- {"Sniper Rifle"}, // 34
- {"Rocket Launcher"}, // 35
- {"Heat-Seeking Rocket Launcher"}, // 36
- {"Flamethrower"}, // 37
- {"Minigun"}, // 38
- {"Satchel Charge"}, // 39
- {"Detonator"}, // 40
- {"Spray Can"}, // 41
- {"Fire Extinguisher"}, // 42
- {"Camera"}, // 43
- {"Night Vision Goggles"}, // 44
- {"Infrared Vision Goggles"}, // 45
- {"Parachute"}, // 46
- {"Fake Pistol"} // 47
- };
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" ----- pspec system loaded----------------");
- print("--------------------------------------\n");
- for(new i;i<MAX_PLAYERS;i++) Spectating[i] = -1;
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- Spectating[playerid] = -1;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i) && Spectating[i] == playerid)
- {
- TogglePlayerSpectating(i, 0);
- GameTextForPlayer(i, " ", 10, 4);
- SendClientMessage(i,0xFFFFFFFF,"The player you was watching has disconnected");
- }
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i) && Spectating[i] == playerid)
- {
- TogglePlayerSpectating(i,0);
- TogglePlayerSpectating(i,1);
- if(!IsPlayerInAnyVehicle(playerid)) PlayerSpectatePlayer(i, playerid);
- else PlayerSpectateVehicle(i,GetPlayerVehicleID(playerid));
- SetPlayerInterior(i,GetPlayerInterior(playerid));
- Spectating[i] = playerid;
- new name[30],str[100];
- GetPlayerName(playerid, name, 30);
- format(str,65,"~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~%s (ID: %d)",name,playerid);
- GameTextForPlayer(i,str,99999,4);
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp("/pspec", cmdtext, true, 3))
- {
- if(!strlen(cmdtext[5])) SendClientMessage(playerid,0xEE2222FF,"[ERROR] Usage: /pspec <id>");
- else
- {
- new id;
- id = strval(cmdtext[5]);
- if (CallRemoteFunction("GetPlayerLevel","i",playerid) < 2) return 0;
- else if(id > MAX_PLAYERS || id < 0 || !IsPlayerConnected(id)) SendClientMessage(playerid,0xEE2222FF,"Invalid Player ID");
- else
- {
- if(Spectating[playerid] == -1)
- {
- GetPlayerPos(playerid,coords[playerid][0],coords[playerid][1],coords[playerid][2]);
- Interior[playerid] = GetPlayerInterior(playerid);
- TogglePlayerSpectating(playerid, 1);
- }
- if(!IsPlayerInAnyVehicle(id)) PlayerSpectatePlayer(playerid, id);
- else PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
- SetPlayerInterior(playerid,GetPlayerInterior(id));
- Spectating[playerid] = id;
- new name[30],str[100];
- GetPlayerName(id, name, 30);
- format(str,65,"~w~%s (ID: %d)~n~",name,id);
- GameTextForPlayer(playerid,str,99999,4);
- }
- }
- return 1;
- }
- else if(!strcmp("/pspecoff", cmdtext, true))
- {
- if(CallRemoteFunction("GetPlayerLevel","i",playerid) < 2) return 0;
- else
- {
- if(Spectating[playerid] == -1) SendClientMessage(playerid,0xEE2222FF,"You aren't watching anyone");
- else
- {
- TogglePlayerSpectating(playerid, 0);
- GameTextForPlayer(playerid, " ", 10, 4);
- }
- return 1;
- }
- }
- else if(!strcmp("/weapons", cmdtext, true,7))
- {
- if(!strlen(cmdtext[9])) SendClientMessage(playerid,0xEE2222FF,"[ERROR] Usage: /weapons <id>");
- else
- {
- new id;
- id = strval(cmdtext[9]);
- if(!IsPlayerAdmin(playerid) && CallRemoteFunction("GetPlayerLevel","i",playerid) < 2) return 0;
- else if(id > MAX_PLAYERS || id < 0 || !IsPlayerConnected(id)) SendClientMessage(playerid,0xEE2222FF,"Invalid Player ID");
- else
- {
- new weapons[13][2];
- for (new i;i<13;i++)
- {
- GetPlayerWeaponData(id,i,weapons[i][0],weapons[i][1]);
- }
- new str[3][256],strtmp,strindex;
- str[0] = "-";
- str[1] = "-";
- str[2] = "-";
- for(new i;i<13;i++)
- {
- if(weapons[i][0] != 0)
- {
- format(str[strtmp],256,"%s %s(%d ammo) -",str[strtmp],aWeaponNames[weapons[i][0]],weapons[i][1]);
- strindex++;
- if(strindex == 4 && strtmp < 2)
- {
- strindex = 0;
- strtmp++;
- }
- }
- }
- new string[200],Float:hp,Float:armour;
- GetPlayerHealth(id,hp);
- GetPlayerArmour(id,armour);
- format(string,200,"%.2f health, %.2f armour; Weapons:",hp, armour);
- SendClientMessage(playerid,0x339933FF,string);
- for(new i;i<3;i++) if(strcmp("-", str[i], true)) SendClientMessage(playerid,0x995555FF,str[i]);
- }
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i) && Spectating[i] == playerid)
- {
- SetPlayerInterior(i,newinteriorid);
- }
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
- {
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i) && Spectating[i] == playerid)
- {
- PlayerSpectateVehicle(i,GetPlayerVehicleID(playerid));
- }
- }
- }
- else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
- {
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i) && Spectating[i] == playerid)
- {
- PlayerSpectatePlayer(i,playerid);
- }
- }
- }
- if (oldstate == PLAYER_STATE_SPECTATING)
- {
- SetPlayerPos(playerid,coords[playerid][0],coords[playerid][1],coords[playerid][2]);
- SetPlayerInterior(playerid,Interior[playerid]);
- Spectating[playerid] = -1;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment