Bad code, help me
#1

Hey, i want to ask one question. I want to made a /leavejob <reason>

And i want to write all server job's(where i'm join): Name_SubName leave job reason: test.

This code:

Код:
CMD:leavejob(playerid, params[])
{
	new reason,STRING[150];
    if(sscanf(params, "u", reason)) return SendClientMessage(playerid, COLOR_RED, "* Using: /leavejob [reason]");
    
    if(spec[ playerid ] == 0) return SendClientMessage(playerid, COLOR_RED, "* Nothing to leave");
    if(spec[ playerid] == POLICE)
    {
    format(String[ playerid ], 150,"%s leave job reason: %s",GetPlayerNameEx[playerid], reason);
    SendMessageToPolice( playerid, COLOR_ORANGE,String[ playerid ]);
    }
    else if(spec[ playerid ] == MEDIC)
    {
        format(STRING,128,"%s leave job reason:%s", GetPlayerNameEx[ playerid ], reason);
        SendMessageToMedics( playerid, COLOR_ORANGE,String[ playerid ]);
    }
    SetPlayerSkin( playerid, UNIFORMS[ playerid ] );
    spec[ playerid ]=0;
    UNIFORMA[ playerid ]=-1;
    UNIFORMD[ playerid ]=false;
    GIVEPLAYERCOLORFROMFROFFESION( playerid );
    SetPlayerSkin( playerid, UNIFORMS[ playerid ] );
    UNIFORMD[ playerid ] = false;
    ApplyAnimation(playerid,"PLAYIDLES","stretch",4.1,0,0,0,0,0);
    SendClientMessage(playerid,COLOR_RED,"* Leaved");
	ZERORANGS( playerid );
	return 1;
}
AND when i write /leavejob test he said Nick_Subname leave job reason: 65535 or nothing.
Reply
#2

Pottus here long time SA-MP fan retired from doing anything serious you seem to suffer from DISS (Downloaded Idiot Scripting Syndrome) this is a common ailment for many people symptoms include the follow.

- In ability to operate a SA-MP server competently
- Lack of understanding of common errors
- Lack of understanding of common coding practices
- Lack of known SA-MP related functions / callbacks
- Persistent questioning on the forum of code that was not written by ones self

If you demonstrate any or more of the above symptoms you are highly advised to immediately visit the tutorial section in which you will find a plethora of information that will equip you to handle such trivial problems such as the one you have posted.
Reply
#3

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Pottus here long time SA-MP fan retired from doing anything serious you seem to suffer from DISS (Downloaded Idiot Scripting Syndrome) this is a common ailment for many people symptoms include the follow.

- In ability to operate a SA-MP server competently
- Lack of understanding of common errors
- Lack of understanding of common coding practices
- Lack of known SA-MP related functions / callbacks
- Persistent questioning on the forum of code that was not written by ones self

If you demonstrate any or more of the above symptoms you are highly advised to immediately visit the tutorial section in which you will find a plethora of information that will equip you to handle such trivial problems such as the one you have posted.
Ye okey, bye.

Any help?
Reply
#4

https://sampwiki.blast.hk/wiki/Sscanf
https://sampwiki.blast.hk/wiki/Sscanf_code

The 'u' parameter is used for finding a name / id which is connected to the server, and it is returning 65535 (INVALID_PLAYER_ID) because the input did not match any connected name / identities.

Change 'u' to 's[128]', and change reason, to reason[128],

Reason being, 's' indicates a string, and it seems like you want to use a formatted one as the variable is titled 'reason'.

You should definitely read the wiki before proceeding with scripting.

Alternatively, you could forget sscanf for now, and just use 'params'.

Example:

Код:
CMD:leavejob(playerid, params[])
{
     static
        string[128];
    
     if(isnull(params))
        return SendClientMessage(...);

     format(string, sizeof(string), "%s has left their job. Reason: %s"...., params);
     // rest of code.
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)