Should return a value? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Should return a value? (
/showthread.php?tid=186243)
Should return a value? -
Mean - 28.10.2010
pawn Код:
dcmd_kick(playerid,params[]){
if(PlayerInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, COLOUR_RED, "You need to be admin to use this command");
new Index;
new tmp[256]; tmp = strtok(params,Index);
new tmp2[256]; tmp2 = strtok(params,Index);
if(!strlen(params)) return
SendClientMessage(playerid, COLOUR_RED, "Usage: /kick [ID] [Reason]") &&
SendClientMessage(playerid, COLOUR_RED, "NOTE: You don't have to put the reason if you don't want to");
new player1;
new string[128];
new playername[MAX_PLAYER_NAME];
new adminname [MAX_PLAYER_NAME];
player1 = strval(tmp);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][AdminLevel]))
{
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
if(!strlen(tmp2))
{
format(string,sizeof(string),"%s got kicked by Administrator %s . Reason:No reason given",playername,adminname);
SendClientMessageToAll(COLOUR_ORANGE,string);
return Kick(player1);
}
else
{
format(string,sizeof(string),"%s got kicked by Administrator %s . Reason: %s.",playername,adminname,params[2]);
SendClientMessageToAll(COLOUR_ORANGE,string);
return Kick(player1);}}}
Код:
C:\DOCUME~1\gazdeki\Desktop\FLHP0~1.3B\FILTER~1\MEANAD~2.PWN(317) : warning 209: function "dcmd_kick" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
How to fix that
Re: Should return a value? -
Cameltoe - 28.10.2010
What about returning an value? lol.
Re: Should return a value? -
Mean - 28.10.2010
That just give me another warn (unreachable code) +
return Kick(player1);
That isnt returning value?
Re: Should return a value? -
Retardedwolf - 28.10.2010
pawn Код:
dcmd_kick(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] < 1) return SendClientMessage(playerid, COLOUR_RED, "You need to be admin to use this command");
else
{
new Index;
new tmp[256]; tmp = strtok(params,Index);
new tmp2[256]; tmp2 = strtok(params,Index);
if(!strlen(params)) return
SendClientMessage(playerid, COLOUR_RED, "Usage: /kick [ID] [Reason]") &&
SendClientMessage(playerid, COLOUR_RED, "NOTE: You don't have to put the reason if you don't want to");
new player1;
new string[128];
new playername[MAX_PLAYER_NAME];
new adminname [MAX_PLAYER_NAME];
player1 = strval(tmp);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][AdminLevel]))
{
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
if(!strlen(tmp2))
{
format(string,sizeof(string),"%s got kicked by Administrator %s . Reason:No reason given",playername,adminname);
SendClientMessageToAll(COLOUR_ORANGE,string);
Kick(player1);
}
else
{
format(string,sizeof(string),"%s got kicked by Administrator %s . Reason: %s.",playername,adminname,params[2]);
SendClientMessageToAll(COLOUR_ORANGE,string);
Kick(player1);
}
}
}
}
return 1;
}
The '
Kick' function does not return any specified value.
Re: Should return a value? -
Mean - 28.10.2010
@ Retardedwolf
it gives me an error for return 1; line
Код:
C:\DOCUME~1\gazdeki\Desktop\FLHP0~1.3B\FILTER~1\MEANAD~2.PWN(314) : warning 209: function "dcmd_kick" should return a value
C:\DOCUME~1\gazdeki\Desktop\FLHP0~1.3B\FILTER~1\MEANAD~2.PWN(315) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
EDIT: : : : : never mind, fixed
Re: Should return a value? -
Retardedwolf - 28.10.2010
Remove the '{' above return 1;