Jump to content

Recommended Posts

Posted
Salut, in acest tutorial veti invata cum sa creati o comanda cu care un jucator poate trimite un mesaj altui jucator.

Atentie, aveti nevoie de ZCMD si sscanf2 pentru a va merge!

 

Pasul 1:

 

Adaugam oriunde in script

CMD:pm(playerid, params[])

{

   return 1;

}

Pasul 2:

Sub

CMD:pm(playerid, params[])

{

Adaugam urmatorul cod:

    new str1[128], msg[128], str2[128], str3[128], giveid;

    if ( sscanf(params, "us[128]", giveid, msg)) return SendClientMessage( playerid, "FOLOSIRE: /pm <ID> <Text>" );

    if ( giveid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "EROARE: "ID Invalid!" );

    format( str1, sizeof(str1), "PM trimis catre {%06x}%s(%d): %s", (GetPlayerColor(giveid) >>> 8), GetName( giveid ), giveid, msg );

 

    format( str2, sizeof(str2), "PM primit de la {%06x}%s(%d): %s", (GetPlayerColor(playerid) >>> 8), GetName( playerid ), playerid, msg );

 

    GameTextForPlayer( giveid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~~h~PM primit!", 3000, 3 );

 

    GameTextForPlayer( playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~~h~PM trimis!", 3000, 3 );

 

    SendClientMessage( playerid, -1, str1 );

 

    SendClientMessage( giveid, -1, str2 );

Pasul 3:

 

Adaugati urmatorul cod in josul scriptului:

stock GetName(playerid)

{

    new Name[24];

    GetPlayerName(playerid, (Name), sizeof(Name));

    return Name;

}

 

  • Upvote 1
  • 1 month later...
  • 2 weeks later...
Posted (edited)

În loc de

 if ( giveid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "EROARE: "ID Invalid!" );

puteai folosi:

if(IsPlayerConnected(giveid)) return SendClientMessage(playerid, -1, "Eroare: ID invalid.");

Pentru că INVALID_PLAYER_ID e definit ca 65535.

Ce să zic, îi ajută p-ăia care vor să învețe să scripteze.

// mai puteai lucra la optimizare. acele două string-uri consumă memorie, puteai face doar unul, și după ce foloseai format, îl trimiteai.

Edited by KruZZBICEPSu

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

moduri samp