My CMD always returning 0 -
AlexBlack - 26.10.2015
Hi, i have a small problem with my command /pc it's always returning to 0 ( Uknown command ) and idk why, i'am using some functions in this command that i will give it below and i think that the problem come from one of this functions, this is my code
PHP код:
CMD:pc(playerid, params[])
{
if(!IsPlayerNearCyberPost(playerid)) return Server(playerid, "You are not near computer.");
if(PosteStatus[IsPlayerNearCyberPost(playerid)] == OCCUPED) return Server(playerid, "This post is already in use.");
SetPlayerInPoste(playerid, IsPlayerNearCyberPost(playerid));
ShowPlayerBrowser(playerid);
return 1;
}
Functions used
PHP код:
stock IsPlayerNearCyberPost(playerid)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, 1947.6533, -1815.8826, 14.0199)) return 1;// POSTE 1
if(IsPlayerInRangeOfPoint(playerid, 2.0, 1944.6198, -1815.7053, 14.0199)) return 2; // POSTE 2
if(IsPlayerInRangeOfPoint(playerid, 2.0, 1940.7903, -1815.7642, 14.0199)) return 3; // POSTE 3
if(IsPlayerInRangeOfPoint(playerid, 2.0, 1940.4321, -1811.0403, 13.5583)) return 4; // POSTE 4
if(IsPlayerInRangeOfPoint(playerid, 2.0, 1943.9427, -1807.9862, 14.0199)) return 5; // POSTE 5
}
return 0;
}
stock SetPlayerInPoste(playerid, postid)
{
switch(postid) {
case 1: SetPlayerPos(playerid, 1947.6533, -1815.8826, 14.0199); // POSTE 1
case 2: SetPlayerPos(playerid, 1944.6198, -1815.7053, 14.0199); // POSTE 2
case 3: SetPlayerPos(playerid, 1940.7903, -1815.7642, 14.0199); // POSTE 3
case 4: SetPlayerPos(playerid, 1940.4321, -1811.0403, 13.5583); // POSTE 4
case 5: SetPlayerPos(playerid, 1943.9427, -1807.9862, 14.0199); // POSTE 5
}
pInfo[playerid][pUsingPost] = postid;
PosteStatus[postid] = OCCUPED;
Freeze(playerid);
ApplyAnimation(playerid,"FOOD","FF_Sit_In",4.1,0,1,1,1,1);
return 1;
}
ShowPlayerBrowser(playerid)
{
for(new i; i < 8; ++i)
{
TextDrawShowForPlayer(playerid, TD_Cyber[i]);
PlayerTextDrawSetString(playerid, PTD_Cyber[playerid][0], ******_URL);
PlayerTextDrawShow(playerid, PTD_Cyber[playerid][0]);
}
return 1;
}
Thank's for advance.
Re: My CMD always returning 0 -
PrO.GameR - 26.10.2015
It's because it doesn't reach return 1
Put debug msgs ( print("something here"); ) after every line to see which one causes the problem, I can't see any problem around
Re: My CMD always returning 0 -
jlalt - 26.10.2015
PHP код:
CMD:pc(playerid, params[])
{
#pragma unused params
if(!IsPlayerNearCyberPost(playerid)) return Server(playerid, "You are not near computer.");
if(PosteStatus[IsPlayerNearCyberPost(playerid)] == OCCUPED) return Server(playerid, "This post is already in use.");
SetPlayerInPoste(playerid, IsPlayerNearCyberPost(playerid));
ShowPlayerBrowser(playerid);
return 1;
}
you did not use params in this command, that what gonna case the unknow command message.
for fix it put #pragma unused params in top of your command like above
Re : My CMD always returning 0 -
AlexBlack - 26.10.2015
Problem solved ! the solution is everything work fine but i have rename the gamemode in the last version and i have forget to rename it in server.cfg Lol ...
Re: My CMD always returning 0 -
AbyssMorgan - 26.10.2015
PHP код:
if(!IsPlayerNearCyberPost(playerid)){
0
} else {
1
}
PHP код:
if(IsPlayerNearCyberPost(playerid) == 0){
0
} else {
whatever
}
PHP код:
if(IsPlayerNearCyberPost(playerid) == 0) return Server(playerid, "You are not near computer.");