SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/01/2012, 08:11 AM   #1
No Fear
Big Clucker
 
Join Date: Nov 2010
Posts: 131
Reputation: 3
Default Working ZCMD /invite

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
No Fear is offline   Reply With Quote
Old 03/01/2012, 08:25 AM   #2
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,828
Reputation: 1401
Default Re: Working ZCMD /invite

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
Konstantinos is offline   Reply With Quote
Old 03/01/2012, 08:49 AM   #3
No Fear
Big Clucker
 
Join Date: Nov 2010
Posts: 131
Reputation: 3
Default Re: Working ZCMD /invite

Nah it's not working i't don't give me the skin..... the uniform other... it's zero....
No Fear is offline   Reply With Quote
Old 03/01/2012, 08:52 AM   #4
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,828
Reputation: 1401
Default Re: Working ZCMD /invite

I only changed this line
pawn Code:
if(id == INVALID_PLAYER_ID)
With your code, it says that if id is Invalid Player continue.
Konstantinos is offline   Reply With Quote
Old 03/01/2012, 08:53 AM   #5
No Fear
Big Clucker
 
Join Date: Nov 2010
Posts: 131
Reputation: 3
Default Re: Working ZCMD /invite

Maybe can you check full code and try to fix?please :/
No Fear is offline   Reply With Quote
Old 03/01/2012, 10:19 AM   #6
No Fear
Big Clucker
 
Join Date: Nov 2010
Posts: 131
Reputation: 3
Default Re: Working ZCMD /invite

Help
No Fear is offline   Reply With Quote
Old 03/01/2012, 10:37 AM   #7
CaHbKo
Huge Clucker
 
Join Date: Nov 2007
Posts: 399
Reputation: 41
Default Re: Working ZCMD /invite

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;
}
CaHbKo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some Zcmd Aint working Buzzbomb Scripting Help 4 19/12/2011 06:53 AM
ZCMD Siren Not Working Smithy Scripting Help 1 30/11/2011 12:09 PM
ZCMD not working in samp 0.3c R5 MickJ Scripting Help 3 18/11/2011 06:08 AM
[Help]Error in /invite and /accept invite deltapro Scripting Help 3 17/10/2011 07:55 PM
MoveObject not working (zcmd) [NTX]MikeQ Help Archive 5 01/06/2010 07:04 PM


All times are GMT. The time now is 02:51 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.