if command successed
#1

i have a cmd that if succeeded it sends a client message else another message
pawn Код:
COMMAND:sync(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) {
        new Float:x,Float:y,Float:z,intid,worldid;
        new weaponsQ[MAX_PLAYERS][13][2];
        GetPlayerPos(playerid,x,y,z);
        intid = GetPlayerInterior(playerid);
        worldid = GetPlayerVirtualWorld(playerid);
        ClearAnimations(playerid);
        SetPlayerSpecialAction(playerid,SPECIAL_ACTION_NONE);
        for (new i = 0; i < 13; i++) {
            GetPlayerWeaponData(playerid,i,weaponsQ[playerid][i][0],weaponsQ[playerid][i][1]);
        }
        SpawnPlayer(playerid);
        SetPlayerPos(playerid,x,y,z);
        SetPlayerInterior(playerid,intid);
        SetPlayerVirtualWorld(playerid,worldid);
        for (new i = 0; i < 13; i++) {
            GivePlayerWeapon(playerid,weaponsQ[playerid][i][0],weaponsQ[playerid][i][1]);
        }
        TogglePlayerControllable(playerid,1);
        if(success) {
            SendClientMessage(playerid,COLOR_GREEN,"success");
        }
        else {
            SendClientMessage(playerid,COLOR_GREEN,"fail");
        }
    }
    else {
        new Float:x2,Float:y2,Float:z2,intid2,worldid2,vehicleid2;
        new weaponsQ2[MAX_PLAYERS][13][2];
        vehicleid2 = GetPlayerVehicleID(playerid);
        GetVehiclePos(vehicleid2,x,y,z);
        intid2 = GetPlayerInterior(playerid);
        worldid2 = GetPlayerVirtualWorld(playerid);
        ClearAnimations(playerid);
        SetPlayerSpecialAction(playerid,SPECIAL_ACTION_NONE);
        for (new i = 0; i < 13; i++) {
            GetPlayerWeaponData(playerid,i,weaponsQ2[playerid][i][0],weaponsQ[playerid][i][1]);
        }
        SetVehicleToRespawn(vehicleid2);
        SetVehiclePos(vehicleid2,x2,y2,z2);
        LinkVehicleToInterior(vehicleid2,intid2);
        SetVehicleVirtualWorld(vehicleid2,worldid2);
        for (new i = 0; i < 13; i++) {
            GivePlayerWeapon(playerid,weaponsQ2[playerid][i][0],weaponsQ[playerid][i][1]);
        }
        TogglePlayerControllable(playerid,1);
        if(success) {
            SendClientMessage(playerid,COLOR_GREEN,"success");
        }
        else {
            SendClientMessage(playerid,COLOR_GREEN,"fail");
        }
    }
}
Reply
#2

Cool command, what's the problem?
Reply
#3

need a succes as a param sucess is undefined
Reply
#4

If you mean like error message if the player type a command that don't exist try using this, that's what i use (I'm using YCMD):
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success){
if(success == 0)return SendClientMessage(playerid, COLOR_GRAY2, "SERVER: Unknown command, use /help for further help.");//If player writes command wrong this will still return it as a true.
}
Hope it helped, otherwise describe more thanks
Reply
#5

nah u got me wrong
this cmd is designed to c if the player is desynced or not
so if he is decynced his health will appear to us not reducing so i dont ban him for hh only reconnect him
Reply
#6

if you want to use this:
Код:
if(success) {
            SendClientMessage(playerid,COLOR_GREEN,"success");
        }
        else {
            SendClientMessage(playerid,COLOR_GREEN,"fail");
        }
You'll have to define a variable like this:
Код:
//this goes into your command start
new success;
//and then you just set this variable to 1 or 0 depending on how the command performed, or you could just send the message directly if it fails or succed.
success = 1;//if it succeded or:
success = 0;//if not
I don't realy get what you are trying to do, but basic you could just send a message if it succeed or not, just like:

Код:
//lets say it succeded here.
SendCleientMessage(playerid, -1, "Success");

//and in this part it didn't succed:
SendCleientMessage(playerid, -1, "Failure");
I don't really get the problem, do you want to like /sync [playerid] and check if another player is synced or do you want to do it on yourself? if you want to check another player then you'll have to use sscanf.
Anyway hope it helped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)