/specoff problem -
Face9000 - 07.12.2010
Hello,i've a little problem.
In my server i've /spec cmd and /specoff.
I need to do,when i do /specoff,the player will return when started spectating.
This is the /spec cmd.
Код:
if(strcmp(cmd, "/spec", true) == 0)
{
if( adminlevel[playerid] >=0 )
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "USAGE: /spec [id]");
return 1;
}
giveplayerid = strval(tmp);
if(giveplayerid == playerid ) return SendClientMessage(playerid, COLOR_RED, "You can't Spectate yourself");
if(giveplayerid != INVALID_PLAYER_ID)
{
TogglePlayerSpectating(playerid, 1);
if(IsPlayerInAnyVehicle(giveplayerid) )
{
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
}
else
{
PlayerSpectatePlayer(playerid, giveplayerid);
}
new msg[128];
GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
format(msg,sizeof(msg),"08,02%s spectating %s.", sendername, giveplayername);
IRC_GroupSay(IRC_Group,"#####",msg);
printf("ID: %i spectates id: %i", playerid, giveplayerid);
SendClientMessage(playerid, COLOR_RED,"Spectating. Type /specoff to cancel spectator !");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Player doesn't exist !");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You do not have the permission !");
}
return 1;
}
And this is /specoff
Код:
if(strcmp(cmdtext, "/specoff", true, 9) == 0)
{
TogglePlayerSpectating(playerid, false);
PlayerSpec[playerid][is] = 0;
return 1;
}
Thanks.
Re: /specoff problem -
iggy1 - 07.12.2010
I'm not sure how spec works never made a spec command tbh. If you want to return to the original position try this
pawn Код:
enum specreturn//top with other global variables
{
Float:retx,
Float:rety,
Float:retz,
Float:retang,
retint,
retworld
};
new s_pos[MAX_PLAYERS][specreturn];//Swap MAX_PLAYERS for MAX_ADMIN or something simalar if you have it.
if(strcmp(cmd, "/spec", true) == 0)
{
if( adminlevel[playerid] > 0 )//this was >= to 0 so anyone could have specced
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "USAGE: /spec [id]");
return 1;
}
giveplayerid = strval(tmp);
if(giveplayerid == playerid ) return SendClientMessage(playerid, COLOR_RED, "You can't Spectate yourself");
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerPos(player, s_pos[playerid][retx], s_pos[playerid][rety],s_pos[playerid][retz]);
GetPlayerFacingAngle(playerid,s_pos[playerid][retang]);
s_pos[playerid][retint] = GetPlayerInterior(playerid);
s_pos[playerid][retworld] = GetPlayerVirtualWorld(playerid);
TogglePlayerSpectating(playerid, 1);
if(IsPlayerInAnyVehicle(giveplayerid) )
{
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
}
else
{
PlayerSpectatePlayer(playerid, giveplayerid);
}
new msg[128];
GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
format(msg,sizeof(msg),"08,02%s spectating %s.", sendername, giveplayername);
IRC_GroupSay(IRC_Group,"#####",msg);
printf("ID: %i spectates id: %i", playerid, giveplayerid);
SendClientMessage(playerid, COLOR_RED,"Spectating. Type /specoff to cancel spectator !");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Player doesn't exist !");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You do not have the permission !");
}
return 1;
}
//specoff
if(strcmp(cmdtext, "/specoff", true, 9) == 0)
{
TogglePlayerSpectating(playerid, false);
PlayerSpec[playerid][is] = 0;
SetPlayerPos(player, s_pos[playerid][retx], s_pos[playerid][rety],s_pos[playerid][retz]);
SetPlayerFacingAngle(playerid,s_pos[playerid][retang]);
SetPlayerVirtualWorld(playerid,s_pos[playerid][retworld]);
SetPlayerInterior(playerid, s_pos[playerid][retint]);
SetCameraBehindPlayer(playerid);
return 1;
}
Re: /specoff problem -
Face9000 - 07.12.2010
Thanks,i got this error when i try to compile:
Код:
C:\Documents and Settings\k\Desktop\COD5.pwn(6719) : error 017: undefined symbol "player"
C:\Documents and Settings\k\Desktop\COD5.pwn(6742) : error 017: undefined symbol "player"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: /specoff problem -
SkizzoTrick - 07.12.2010
A sepctating command is very simple,all you need to do is to save the coords before specing and put them on /specoff
Now about your script,im always putting publics
do that enum like iggy said and then create a public.
When his typing /specoff use that public to return him to his old position
Re: /specoff problem -
Face9000 - 07.12.2010
I've fixed thanks.