CMD:cptest(playerid,params[]) { foreach(new i : checkpoints) { if(!IsPlayerInDynamicCP(playerid,CP[i][cpid])) { SendClientMessage(playerid,-1,"You are not in checkpoint!"); return 1; } } . . . . . return 1; }
CMD:cptest(playerid,params[]) { foreach(new i : checkpoints) { if(IsPlayerInDynamicCP(playerid,CP[i][cpid])) { //Yay we found out that player is in these CP, do what you want... return 1; } } //If we ever reach these point in code that means player is not in any CP from loop.... SendClientMessage(playerid,-1,"You are not in checkpoint!"); return 1; }
You will start looping thru all CP's (i guess only valid ones but its not the point now)
Then you check if player is not inside CP, and if he is not you send error message. After that you just return, meaning you terminate your code. Basically, if player is not in first CP from that loop, it will send error and finish processing your command... Try these... Код:
CMD:cptest(playerid,params[]) { foreach(new i : checkpoints) { if(IsPlayerInDynamicCP(playerid,CP[i][cpid])) { //Yay we found out that player is in these CP, do what you want... return 1; } } //If we ever reach these point in code that means player is not in any CP from loop.... SendClientMessage(playerid,-1,"You are not in checkpoint!"); return 1; } |