Working ZCMD /invite
#1

Hi, i rlly need simple command /invite faction, on zcmd/sscanf - please simple command cuz i made something wrong with mines....

pawn Code:
new
        id;

    if(sscanf( params, "u", id )) return SendClientMessage(playerid, COLOR_RED,"Komanda: /priimti [ћaidėjo nick / id]");

    if(PVar[playerid][pFactionL] > 0)
    {

        if(id == INVALID_PLAYER_ID)
        {
            if(PVar[id][pFaction] == 0)
            {
                new string[256],name[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "Pakvietei %s dirbti į savo frakcija",name);
                SendClientMessage(playerid, -1,string);

                if     ( PVar[ playerid][pFactionL ] == 1 ) SendClientMessage( id,-1,"Jūs priimtas į policijos departamentą" ); SetPlayerSkin( id, 120 ); PVar[ id ][ pUniform ] = 120; PVar[ id ][ pUniformc ] = true;
                if( PVar[ playerid][pFactionL ] == 2 ) SendClientMessage( id,-1,"Jūs priimtas į medicinos departamentą" ); SetPlayerSkin( id, 71 ); PVar[ id ][ pUniform ] = 71; PVar[ id ][ pUniformc ] = true;
                if( PVar[ playerid][pFactionL ] == 3 ) SendClientMessage( id,-1,"Jūs priimtas į mechanikų departamentą" ); SetPlayerSkin( id, 50 ); PVar[ id ][ pUniform ] = 50; PVar[ id ][ pUniformc ] = true;
                if( PVar [playerid][pFactionL ] == 4 ) SendClientMessage( id,-1,"Jūs priimtas į taksi departamentą" );   SetPlayerSkin( id, 223); PVar[ id ][ pUniform ] = 223; PVar[ id ][ pUniformc ] = true;


                return 1;
            }
            else
            {
                GameTextForPlayer(playerid,"~r~Zaidejas turi darba.",5000,3);
            }
        }
        else
        {
            GameTextForPlayer(playerid,"~r~Player is not connected.",5000,3);
        }
    }
    else
    {
        GameTextForPlayer(playerid,"~r~Tu ne direktorius.",5000,3);
    }
    return 1;
}
everytime i used it says player is not connected
Reply
#2

pawn Code:
CMD:priimti(playerid, params[])
{
    new
        id;
    if(sscanf( params, "u", id )) return SendClientMessage(playerid, COLOR_RED,"Komanda: /priimti [žaidejo nick / id]");
    if(PVar[playerid][pFactionL] > 0) {
        if(id != INVALID_PLAYER_ID) {
            if(PVar[id][pFaction] == 0) {
                new string[256],name[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "Pakvietei %s dirbti i savo frakcija",name);
                SendClientMessage(playerid, -1,string);

                if     ( PVar[ playerid][pFactionL ] == 1 ) SendClientMessage( id,-1,"Jus priimtas i policijos departamenta" ); SetPlayerSkin( id, 120 ); PVar[ id ][ pUniform ] = 120; PVar[ id ][ pUniformc ] = true;
                if( PVar[ playerid][pFactionL ] == 2 ) SendClientMessage( id,-1,"Jus priimtas i medicinos departamenta" ); SetPlayerSkin( id, 71 ); PVar[ id ][ pUniform ] = 71; PVar[ id ][ pUniformc ] = true;
                if( PVar[ playerid][pFactionL ] == 3 ) SendClientMessage( id,-1,"Jus priimtas i mechaniku departamenta" ); SetPlayerSkin( id, 50 ); PVar[ id ][ pUniform ] = 50; PVar[ id ][ pUniformc ] = true;
                if( PVar [playerid][pFactionL ] == 4 ) SendClientMessage( id,-1,"Jus priimtas i taksi departamenta" );   SetPlayerSkin( id, 223); PVar[ id ][ pUniform ] = 223; PVar[ id ][ pUniformc ] = true;

                return 1;
            }
            else {
                GameTextForPlayer(playerid,"~r~Zaidejas turi darba.",5000,3);
            }
        }
        else {
            GameTextForPlayer(playerid,"~r~Player is not connected.",5000,3);
        }
    }
    else {
        GameTextForPlayer(playerid,"~r~Tu ne direktorius.",5000,3);
    }
    return 1;
}
It's != so, the player is valid ID
Reply
#3

Nah it's not working i't don't give me the skin..... the uniform other... it's zero....
Reply
#4

I only changed this line
pawn Code:
if(id == INVALID_PLAYER_ID)
With your code, it says that if id is Invalid Player continue.
Reply
#5

Maybe can you check full code and try to fix?please :/
Reply
#6

Help
Reply
#7

pawn Code:
if(id == INVALID_PLAYER_ID)
Code only proceeds if id does NOT contain a valid player. So you don't let the script work with real players.

You do not set the id's faction. PVar[id][pFactionL] = PVar [playerid][pFactionL]?

This code
pawn Code:
if     ( PVar[ playerid][pFactionL ] == 1 ) SendClientMessage( id,-1,"Jūs priimtas į policijos departamentą" ); SetPlayerSkin( id, 120 ); PVar[ id ][ pUniform ] = 120; PVar[ id ][ pUniformc ] = true;
                if( PVar[ playerid][pFactionL ] == 2 ) SendClientMessage( id,-1,"Jūs priimtas į medicinos departamentą" ); SetPlayerSkin( id, 71 ); PVar[ id ][ pUniform ] = 71; PVar[ id ][ pUniformc ] = true;
                if( PVar[ playerid][pFactionL ] == 3 ) SendClientMessage( id,-1,"Jūs priimtas į mechanikų departamentą" ); SetPlayerSkin( id, 50 ); PVar[ id ][ pUniform ] = 50; PVar[ id ][ pUniformc ] = true;
                if( PVar [playerid][pFactionL ] == 4 ) SendClientMessage( id,-1,"Jūs priimtas į taksi departamentą" );   SetPlayerSkin( id, 223); PVar[ id ][ pUniform ] = 223; PVar[ id ][ pUniformc ] = true;
Can be translated as
pawn Code:
if( PVar[ playerid][pFactionL ] == 1 ) SendClientMessage( id,-1,"Jūs priimtas į policijos departamentą" );
                SetPlayerSkin( id, 120 );
                PVar[ id ][ pUniform ] = 120;
                PVar[ id ][ pUniformc ] = true;
                if( PVar[ playerid][pFactionL ] == 2 ) SendClientMessage( id,-1,"Jūs priimtas į medicinos departamentą" );
                SetPlayerSkin( id, 71 );
                PVar[ id ][ pUniform ] = 71;
                PVar[ id ][ pUniformc ] = true;
                if( PVar[ playerid][pFactionL ] == 3 ) SendClientMessage( id,-1,"Jūs priimtas į mechanikų departamentą" );
                SetPlayerSkin( id, 50 );
                PVar[ id ][ pUniform ] = 50;
                PVar[ id ][ pUniformc ] = true;
                if( PVar [playerid][pFactionL ] == 4 ) SendClientMessage( id,-1,"Jūs priimtas į taksi departamentą" );
                SetPlayerSkin( id, 223);
                PVar[ id ][ pUniform ] = 223;
                PVar[ id ][ pUniformc ] = true;
So as you can see, SetPlayerSkin and PVar operations get ran INDEPENDENTLY from pFactionL value. Only SendClientMessage depends on it.

Here's your code (note that I used commas instead of semicolons in the 'if(PVar[playerid][pFactionL] == x)' checks)
pawn Code:
CMD:priimti(playerid, params[])
{  
    new id;
    if(sscanf( params, "u", id )) return SendClientMessage(playerid, COLOR_RED,"Komanda: /priimti [ћaidejo nick / id]");

    if(PVar[playerid][pFactionL] > 0)
    {
        if(id != INVALID_PLAYER_ID)
        {
            if(PVar[id][pFaction] == 0)
            {
                new string[128],name[MAX_PLAYER_NAME];
                //string[128] because SendClientMessage can only send maximum 128 chars!
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "Pakvietei %s dirbti i savo frakcija",name);
                SendClientMessage(playerid, -1,string);

                if(PVar[playerid][pFactionL] == 1 ) SendClientMessage( id,-1,"Jus priimtas i policijos departamenta" ), SetPlayerSkin( id, 120 ), PVar[ id ][ pUniform ] = 120, PVar[ id ][ pUniformc ] = true;
                if(PVar[playerid][pFactionL] == 2 ) SendClientMessage( id,-1,"Jus priimtas i medicinos departamenta" ), SetPlayerSkin( id, 71 ), PVar[ id ][ pUniform ] = 71, PVar[ id ][ pUniformc ] = true;
                if(PVar[playerid][pFactionL] == 3 ) SendClientMessage( id,-1,"Jus priimtas i mechaniku departamenta" ), SetPlayerSkin( id, 50 ), PVar[ id ][ pUniform ] = 50, PVar[ id ][ pUniformc ] = true;
                if(PVar[playerid][pFactionL] == 4 ) SendClientMessage( id,-1,"Jus priimtas i taksi departamenta" ),   SetPlayerSkin( id, 223), PVar[ id ][ pUniform ] = 223, PVar[ id ][ pUniformc ] = true;
               
                PVar[id][pFactionL] = PVar[playerid][pFactionL];

                return 1;
            }
            else
            {
                GameTextForPlayer(playerid,"~r~Zaidejas turi darba.",5000,3);
            }
        }
        else
        {
            GameTextForPlayer(playerid,"~r~Player is not connected.",5000,3);
        }
    }
    else
    {
        GameTextForPlayer(playerid,"~r~Tu ne direktorius.",5000,3);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)