SHOW:
|
|
- or go back to the newest paste.
1 | - | //Simple spectate script |
1 | + | //Simple spectate script, GTA3 Liberty Unleashed . |
2 | //Home Page - http://liberty-unleashed.co.uk/ | |
3 | //Author Vetal © 2012 All Rights Reserved. | |
4 | ||
5 | ||
6 | g_Enabled <- false; | |
7 | g_MyOldPos <- Vector(0.0, 0.0, 0.0); | |
8 | pPlayer <- FindLocalPlayer(); | |
9 | ||
10 | //Custom values (start). You can set this values whatever you want: | |
11 | g_TimerUpdate <- 10; | |
12 | g_Distance <- 5; | |
13 | //Custom values (end) | |
14 | ||
15 | ||
16 | function onClientCommand( szCmd, szParams ) | |
17 | { | |
18 | if ( szCmd == "spec" ){ | |
19 | local p, playerid; | |
20 | if(!szParams){ | |
21 | Message( "USAGE: /spec <playerid>"); | |
22 | return false; } | |
23 | if ( szParams == "off" && g_Enabled == true ){ | |
24 | RestoreMyPlace(); | |
25 | Message( "Spectate has been disabled"); | |
26 | return false; } | |
27 | if(g_Enabled == true){ | |
28 | Message( "Another spectate is active, to disable use /spec off"); | |
29 | return false; } | |
30 | if(!IsNum( szParams )){ | |
31 | Message( "USAGE: /spec <playerid>"); | |
32 | return false; } | |
33 | playerid = szParams.tointeger(); | |
34 | if(playerid == pPlayer.ID){ | |
35 | Message( "You cant spectate yourself !"); | |
36 | return false; } | |
37 | p = FindPlayer( playerid ); | |
38 | if(p){ | |
39 | pPlayer.Frozen = true; | |
40 | g_Enabled = true; | |
41 | Message( "Spectate Mode is ON. To Turn it Off, use /spec off"); | |
42 | g_MyOldPos = pPlayer.Pos; | |
43 | NewTimer("SpectatorOn", g_TimerUpdate, 1, playerid); } else | |
44 | { Message( "Can't find the player."); } } | |
45 | } | |
46 | ||
47 | ||
48 | ||
49 | ||
50 | function SpectatorOn(playerid) | |
51 | { | |
52 | local p, camPos, v, myPos; | |
53 | p = FindPlayer( playerid ); | |
54 | if(!p){ RestoreMyPlace(); | |
55 | return false; } | |
56 | v = p.Pos; | |
57 | camPos = Vector( v.x + g_Distance, v.y, v.z + g_Distance); | |
58 | myPos = Vector( v.x + g_Distance, v.y, v.z + 100); | |
59 | SetCameraMatrix( camPos, v ); | |
60 | pPlayer.Pos = myPos; | |
61 | if(g_Enabled == true) { NewTimer("SpectatorOn", g_TimerUpdate, 1, playerid); } | |
62 | if(g_Enabled == false){ RestoreMyPlace(); } | |
63 | } | |
64 | ||
65 | function RestoreMyPlace(){ | |
66 | ||
67 | RestoreCamera(); | |
68 | g_Enabled = true; //Needed for not being killed from falling from the sky | |
69 | pPlayer.Pos = g_MyOldPos; | |
70 | pPlayer.Frozen = false; | |
71 | NewTimer("RestoreStatus", 800, 1); | |
72 | } | |
73 | ||
74 | function onScriptLoad() | |
75 | { print("Vetal's simple spectate script loaded"); } | |
76 | ||
77 | function RestoreStatus(){ g_Enabled = false; } | |
78 | ||
79 | function onClientShot( attacker, weapon, bodypart ) | |
80 | { | |
81 | if(g_Enabled == true) { | |
82 | return 0; } | |
83 | return 1; | |
84 | } | |
85 | ||
86 | function onClientHurt( entity ) | |
87 | { | |
88 | if(g_Enabled == true) { | |
89 | return 0; } | |
90 | return 1; | |
91 | } |