togglespec (/ts) -
suni - 26.02.2015
hello can can someone teach me how to script a togglespec (/ts)?
i mean like if im ingame and i dont want no one to spec me i can just type /ts. then when a person try to spec me it a send a message saying "u cannot spec this player as they have their spec disable". please help me.
Re: togglespec (/ts) -
CalvinC - 26.02.2015
Create a variable first:
pawn Код:
new ToggleSpectate[MAX_PLAYERS];
Then check if it's set to 0 or 1 when using /ts, and set to to 1 or 0 accordingly.
Then in your spectating command, check if it's 0 or 1.
EDIT: Just noticed, wrong section, next time post this under Scripting Help.
Re: togglespec (/ts) -
Crayder - 26.02.2015
Wrong section and you may using the wrong playerids. I can't really tell if you don't show us the code. Nobody is going to help you here though, neither am I after this.
Quote:
Originally Posted by CalvinC
Create a variable first:
pawn Код:
new ToggleSpectate[MAX_PLAYERS];
Then check if it's set to 0 or 1 when using /ts, and set to to 1 or 0 accordingly.
Then in your spectating command, check if it's 0 or 1.
|
That's not the problem he is describing, he says the message is sent to the wrong person. Also, while your teaching him why not show him how to use a boolean instead of this integer check?
Re: togglespec (/ts) -
suni - 26.02.2015
sorry for posting the wrong place.
Respuesta: togglespec (/ts) -
alexus - 26.02.2015
First create a global boolean variable:
Код:
new bool:spec_enabled[MAX_PLAYERS]
Then initialize it
Код:
// OnGameModeInit:
for (new i=0, i<MAX_PLAYERS, i++) spec_enabled[i] = true;
// OnPlayerConnect
spec_enabled[playerid] = true;
Modify your /spec command as follows
Код:
dcmd_spec(playerid, params[])
{
if (strlen(params) && IsNumeric(params) && strval(params) != playerid)
{
new spected = strval(params);
if (!spec_enabled[spected]) return SendClientMessage(playerid, 0xFFA000FF, "[ERROR]: that player has spec disabled!");
else
{
// ... your /spec code here
}
return 1;
}
else return SendClientMessage(playerid, 0xFFA000FF, "[USAGE]: /spec [playerid]");
}
Your /ts command could be something like:
Код:
dcmd_ts(playerid, params[])
{
#pragma unused params
if (spec_enabled[playerid])
{
spec_enabled[playerid] = false;
SendClientMessage[playerid, 0xFF0000FF, "*** You've become invisible...");
}
else
{
spec_enabled[playerid] = true;
SendClientMessage[playerid, 0x00A000FF, "*** You've become visible...");
}
}
Perhaps there are better ways, but the idea is the use of booleans to define stats of players.
Re: togglespec (/ts) -
suni - 26.02.2015
im using zcmd
Re: togglespec (/ts) -
Abagail - 26.02.2015
ZCMD is just a command processor, they told you exactly how to do it. It'll be your job to convert dcmd to ZCMD. There are many tutorials on this.
Re: togglespec (/ts) -
suni - 26.02.2015
C:\Users\jahbo_000\Desktop\SAMP\pawno\include\rDut ils.inc(231) : error 017: undefined symbol "StripNewLine"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(87) : error 001: expected token: ";", but found "forward"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(684) : warning 201: redefinition of constant/macro (symbol "COLOR_YELLOW")
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(796) : error 017: undefined symbol "ConfigPrint"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(807) : error 017: undefined symbol "cmd"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(829) : error 017: undefined symbol "StripNewLine"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(846) : error 017: undefined symbol "strtok"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(845) : warning 203: symbol is never used: "idx"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(863) : error 017: undefined symbol "strtok"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(862) : warning 203: symbol is never used: "idx"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1006) : error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1011) : error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1022) : error 017: undefined symbol "PreloadAnimLib"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1046) : error 017: undefined symbol "Path"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1046) : error 017: undefined symbol "Path"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1085) : error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1096) : error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(109

: error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1116) : error 017: undefined symbol "TempBanCheck"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1117) : error 017: undefined symbol "Path"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1129) : error 017: undefined symbol "Path"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1135) : error 017: undefined symbol "Path"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1171) : error 017: undefined symbol "SaveStats"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1177) : error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(117

: error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1179) : error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1194) : error 017: undefined symbol "StopSpectate"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1197) : error 017: undefined symbol "GetName"
C:\Users\jahbo_000\Desktop\SAMP\filterscripts\AFS. pwn(1304) : error 017: undefined symbol "GetName"
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
26 Errors.
Re: togglespec (/ts) -
suni - 26.02.2015
i fixed the rest but im having problems with this one
error 021: symbol already defined: "i"
Re: togglespec (/ts) -
Abagail - 26.02.2015
Well, I just noticed that this is a scripting-based question in the General section so this actually is not the right place to be asking for scripting help.
Try posting in the "Scripting Help" section.