My CMD always returning 0
#1

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(playeridparams[])
{
    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(playeridIsPlayerNearCyberPost(playerid));
    
ShowPlayerBrowser(playerid);
    return 
1;

Functions used

PHP код:
stock IsPlayerNearCyberPost(playerid)
{
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerInRangeOfPoint(playerid2.01947.6533, -1815.882614.0199)) return 1;// POSTE 1
        
if(IsPlayerInRangeOfPoint(playerid2.01944.6198, -1815.705314.0199)) return 2// POSTE 2
        
if(IsPlayerInRangeOfPoint(playerid2.01940.7903, -1815.764214.0199)) return 3// POSTE 3
        
if(IsPlayerInRangeOfPoint(playerid2.01940.4321, -1811.040313.5583)) return 4// POSTE 4
        
if(IsPlayerInRangeOfPoint(playerid2.01943.9427, -1807.986214.0199)) return 5// POSTE 5
    
}
    return 
0;
}
stock SetPlayerInPoste(playeridpostid)
{
    switch(
postid) {
        case 
1SetPlayerPos(playerid1947.6533, -1815.882614.0199); // POSTE 1
        
case 2SetPlayerPos(playerid1944.6198, -1815.705314.0199); // POSTE 2
        
case 3SetPlayerPos(playerid1940.7903, -1815.764214.0199); // POSTE 3
        
case 4SetPlayerPos(playerid1940.4321, -1811.040313.5583); // POSTE 4
        
case 5SetPlayerPos(playerid1943.9427, -1807.986214.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 
i8; ++i)
    {
        
TextDrawShowForPlayer(playeridTD_Cyber[i]);
        
PlayerTextDrawSetString(playeridPTD_Cyber[playerid][0], ******_URL);
        
PlayerTextDrawShow(playeridPTD_Cyber[playerid][0]);
    }
    return 
1;

Thank's for advance.
Reply
#2

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
Reply
#3

PHP код:
CMD:pc(playeridparams[])
{
    
#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(playeridIsPlayerNearCyberPost(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
Reply
#4

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 ...
Reply
#5

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."); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)