Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- public Plugin:myinfo =
- {
- name = "Engineer ThirdView",
- author = "Ice :D",
- description = "Ce plugin permet changer son mode de vue",
- version = "1.0",
- url = "http://engineer.redby.fr"
- }
- public OnPluginStart()
- {
- RegConsoleCmd("say", Command_Say) // It's override the say command ;P
- }
- // THe console command
- public Action:Command_Say(client, args)
- {
- new String:text[192]
- GetCmdArgString(text, sizeof(text))
- new startidx = 0
- if (text[0] == '"')
- {
- startidx = 1
- /* Strip the ending quote, if there is one */
- new len = strlen(text);
- if (text[len-1] == '"')
- {
- text[len-1] = '\0'
- }
- }
- if (StrEqual(text[startidx], "!thirdperson"))
- {
- ActiveThirdPerson(client);
- }
- if (StrEqual(text[startidx], "!firstperson"))
- {
- ActiveFirstPerson(client);
- }
- /* Let say continue normally */
- return Plugin_Continue
- }
- public IsClientConnectedIngameAlive(client) // If player is alive and ingame but now u can make better with SM function
- {
- if(IsClientConnectedIngame(client))
- {
- if(IsPlayerAlive(client) == true && IsClientObserver(client) == false)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- public IsClientConnectedIngame(client)
- {
- if(client > 0 && client <= MaxClients){
- if(IsClientInGame(client) == true){
- return true;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
- public ActiveThirdPerson(client){ //Simple function
- if(IsClientConnectedIngameAlive(client)){
- SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", 0);
- SetEntProp(client, Prop_Send, "m_iObserverMode", 1);
- SetEntProp(client, Prop_Send, "m_bDrawViewmodel", 0);
- }
- }
- public ActiveFirstPerson(client){
- if(IsClientConnectedIngameAlive(client)){
- SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", -1);
- SetEntProp(client, Prop_Send, "m_iObserverMode", 0);
- SetEntProp(client, Prop_Send, "m_bDrawViewmodel", 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement