SA-MP Forums Archive
is this code right? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: is this code right? (/showthread.php?tid=591561)



is this code right? - ahameed4755 - 13.10.2015

hi im making a command is this code right or wrong? im getting a error

Код:
stock OldSkin(targetid)
{
OldSkin == GetPlayerSkin(targetid)
}
Код:
CMD:trolladutyoff(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]:You are not rcon admin");
new targetid,str[75];
if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]:Usage(playerid/name)");
SetPlayerSkin(targetid,OldSkin); // error line!
SetPlayerColor(playerid,-1);
format(str,sizeof(str),"~G~Admin Duty Disabled.");
GameTextForPlayer(targetid,str,3000,3);
return 1;
}
error:- (113) : error 076: syntax error in the expression, or invalid function call


Re: is this code right? - SecretBoss - 13.10.2015

You must put oldskin on sscanf

EDIT:

I can't really understand what you want to do


Re: is this code right? - IceBilizard - 13.10.2015

why you are creating stock for it you can make a variable for that example

pawn Код:
new OldSkin;//At top of script
then

at on duty command

pawn Код:
OldSkin = GetPlayerSkin(playerid);
then at off duty command

pawn Код:
SetPlayerSkin(playerid, OldSkin);



Re: is this code right? - Karan007 - 13.10.2015

Change the error line to:

Код:
SetPlayerSkin(targetid, OldSkin(targetid));
Check it and tell me again!


Re: is this code right? - jlalt - 13.10.2015

for save:
PHP код:
oldskin[playerid] = GetPlayerSkin(playerid); 
for use:
PHP код:
CMD:trolladutyoff(playerid,params[])
{
if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]:You are not rcon admin");
new 
targetid,str[75];
if(
sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]:Usage(playerid/name)");
SetPlayerSkin(targetid,oldskin[targetid]); // error line!
SetPlayerColor(playerid,-1);
format(str,sizeof(str),"~G~Admin Duty Disabled.");
GameTextForPlayer(targetid,str,3000,3);
return 
1;

on the top:
PHP код:
new oldskin[MAX_PLAYERS]; 
about the stock
http://forum.sa-mp.com/showthread.ph...ht=abuse+stock


Re: is this code right? - ahameed4755 - 13.10.2015

Quote:
Originally Posted by jlalt
Посмотреть сообщение
for save:
PHP код:
oldskin[playerid] = GetPlayerSkin(playerid); 
for use:
PHP код:
CMD:trolladutyoff(playerid,params[])
{
if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]:You are not rcon admin");
new 
targetid,str[75];
if(
sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]:Usage(playerid/name)");
SetPlayerSkin(targetid,oldskin[targetid]); // error line!
SetPlayerColor(playerid,-1);
format(str,sizeof(str),"~G~Admin Duty Disabled.");
GameTextForPlayer(targetid,str,3000,3);
return 
1;

on the top:
PHP код:
new oldskin[MAX_PLAYERS]; 
about the stock
http://forum.sa-mp.com/showthread.ph...ht=abuse+stock
no it didnt worked

it gets back to cj skin.


Re: is this code right? - Unte99 - 13.10.2015

Quote:
Originally Posted by ahameed4755
Посмотреть сообщение
no it didnt worked

it gets back to cj skin.
Set the old skin variable when the player goes on duty.


Re: is this code right? - jlalt - 13.10.2015

if it still the same , [ cj skin ] try to change old
PHP код:
new oldskin[MAX_PLAYERS]; 
with
PHP код:
new Float:oldskin[MAX_PLAYERS]; 



AW: Re: is this code right? - NaS - 14.10.2015

Quote:
Originally Posted by jlalt
Посмотреть сообщение
if it still the same , [ cj skin ] try to change old
PHP код:
new oldskin[MAX_PLAYERS]; 
with
PHP код:
new Float:oldskin[MAX_PLAYERS]; 
Why Float? That's totally wrong....

Here's a working one:

Top of script:

Код:
new DutyOldSkin[MAX_PLAYERS] = {-1, ...}; // Also used for determining if the player is on duty; you can change that
In a "/duty" command (which toggles duty on/off):

Код:
// Put Admin Level Check here
if(DutyOldSkin[playerid] == -1)
{
DutyOldSkin[playerid] = GetPlayerSkin(playerid);
SetPlayerSkin(playerid, 75); // 75 as example duty-skin
}
else
{
SetPlayerSkin(playerid, DutyOldSkin[playerid]);
DutyOldSkin[playerid] = -1;
}
OnPlayerDisconnect:

Код:
DutyOldSkin[playerid] = -1;



Re: AW: Re: is this code right? - ahameed4755 - 14.10.2015

Quote:
Originally Posted by NaS
Посмотреть сообщение
Why Float? That's totally wrong....

Here's a working one:

Top of script:

Код:
new DutyOldSkin[MAX_PLAYERS] = {-1, ...}; // Also used for determining if the player is on duty; you can change that
In a "/duty" command (which toggles duty on/off):

Код:
// Put Admin Level Check here
if(DutyOldSkin[playerid] == -1)
{
DutyOldSkin[playerid] = GetPlayerSkin(playerid);
SetPlayerSkin(playerid, 75); // 75 as example duty-skin
}
else
{
SetPlayerSkin(playerid, DutyOldSkin[playerid]);
DutyOldSkin[playerid] = -1;
}
OnPlayerDisconnect:

Код:
DutyOldSkin[playerid] = -1;
ok thanks. i will try!