Issues with /spectate command
#6

Quote:
Originally Posted by Undef1ned
View Post
Test it.

PHP Code:
CMD:spec(playerid, params[]) 
{ 
    if(
PlayerInfo[playerid][pAdmin] <= 0) return SCM(playerid, COLOR_ERROR,"You do not have the required access to execute this command."); 
    if(
IsSpecing[playerid]) 
    { 
        
IsSpecing[playerid] = 0;
        
IsBeingSpeced[SpecID[playerid]] = 0;
        
TogglePlayerSpectating(playerid, false);
        
SetPlayerPos(playerid, SpecX[playerid], SpecY[playerid], SpecZ[playerid]);
        
SetPlayerFacingAngle(playerid, SpecR[playerid]);
        
SetPlayerInterior(playerid, SpecI[playerid]);
        
SetPlayerVirtualWorld(playerid, SpecW[playerid]);
        new 
str[128]; 
        
format(str, sizeof(str), "%s %s(%i) has quit spectating %s(%i).", ReturnAdminLevel(playerid), ReturnICName(playerid), playerid, ReturnICName(SpecID[playerid]), SpecID[playerid]); 
        
ABroadCast(COLOR_SADMIN, str, 1); 
        new 
action[20]; 
        
format(action, sizeof(action), "spec end"); 
        new 
query[250]; 
        
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO logs_punishments(acc_dbid, acc_name, ip_address, time, action, reason, by_acc_dbid, by_acc_name) VALUES('%i', '%e', '%e', UTC_TIMESTAMP(), '%e', '-1', '%i', '%e')", PlayerInfo[params[0]][pDBID], ReturnName(params[0]), ReturnIP(params[0]), action, PlayerInfo[playerid][pDBID], ReturnName(playerid)); 
        
mysql_tquery(g_SQL, query);
        return 
1;
    }
    if(
sscanf(params, "u", params[0])) return SCM(playerid, COLOR_INFO, "/spec [name/id](leave blank to quit spectating)"); 
    if(
params[0] == playerid)  return SCM(playerid, COLOR_ERROR, "You can not use this command on yourself."); 
    if(!
IsPlayerConnected(params[0])) return SCM(playerid, COLOR_ERROR, "That account is not connected."); 
    if(!
Spawned[params[0]]) return SCM(playerid, COLOR_ERROR, "That player has not logged in or spawned yet."); 
    
    if(
IsSpecing[params[0]]) return SCMEx(playerid, COLOR_ERROR, "%s(%i) is spectating %s(%i) right now. Try again later.", ReturnICName(params[0]), params[0], ReturnICName(SpecID[params[0]]), SpecID[params[0]]); 
    
OnPlayerSave(playerid); // saves the player data so that they don't get rollbacked for not being spawned if they quit in spec mode. 
    
GetPlayerPos(playerid, SpecX[playerid], SpecY[playerid], SpecZ[playerid]); 
    
GetPlayerFacingAngle(playerid, SpecR[playerid]); 
    
SpecI[playerid] = GetPlayerInterior(playerid); 
    
SpecW[playerid] = GetPlayerVirtualWorld(playerid); 
    
TogglePlayerSpectating(playerid, true);
    
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(params[0]));
    
SetPlayerInterior(playerid, GetPlayerInterior(params[0]));
    if(
IsPlayerInAnyVehicle(params[0])) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(params[0]));
    else 
PlayerSpectatePlayer(playerid, params[0]);
    
IsSpecing[playerid] = 1; 
    
IsBeingSpeced[params[0]] = 1; 
    
SpecID[playerid] = params[0]; 
    new 
str[128]; 
    
format(str, sizeof(str), "%s %s(%i) is spectating %s(%i).", ReturnAdminLevel(playerid), ReturnICName(playerid), playerid, ReturnICName(params[0]), params[0]); 
    
ABroadCast(COLOR_SADMIN, str, 1); 
    new 
action[20]; 
    
format(action, sizeof(action), "spec start"); 
    new 
query[250]; 
    
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO logs_punishments(acc_dbid, acc_name, ip_address, time, action, reason, by_acc_dbid, by_acc_name) VALUES('%i', '%e', '%e', UTC_TIMESTAMP(), '%e', '-1', '%i', '%e')", PlayerInfo[params[0]][pDBID], ReturnName(params[0]), ReturnIP(params[0]), action, PlayerInfo[playerid][pDBID], ReturnName(playerid)); 
    
mysql_tquery(g_SQL, query); 
    return 
1;
} 
Why did you put params[0], what does that do?
Reply


Messages In This Thread
Issues with /spectate command - by Stefhan - 16.01.2019, 21:37
Re: Issues with /spectate command - by Stefhan - 17.01.2019, 12:56
Re: Issues with /spectate command - by Undef1ned - 17.01.2019, 15:26
Re: Issues with /spectate command - by Stefhan - 17.01.2019, 16:38
Re: Issues with /spectate command - by Undef1ned - 17.01.2019, 19:57
Re: Issues with /spectate command - by Stefhan - 17.01.2019, 20:17
Re: Issues with /spectate command - by Undef1ned - 18.01.2019, 00:40
Re: Issues with /spectate command - by Stefhan - 19.01.2019, 17:17

Forum Jump:


Users browsing this thread: 1 Guest(s)