Szerző Téma: Megpróbálás  (Megtekintve 1980 alkalommal)

Nem elérhető SnicK

  • 7521
    • Profil megtekintése
Megpróbálás
« Dátum: 2010. Április 05. - 14:53:17 »
0 Show voters
Régen szükségem volt rá mind kezdo Godfather mód usernek.
Lehet hogy másoknak is gondja akadt az elkészítésével mint nekem anno, ezért gondoltam kicsit segítek.
A parancs lényege az mint a /me-nek cselekvést írhatunk ki vele.
Itt két lehetoség van: sikerül-nemsikerül.
A szkriptet berakom Ismeretlen változatba is.
UPDATE: Nincs alsó csík a névnél!
Sima változat, nevet is kiirja:
 

if(strcmp(cmd, \"/try\", true) == 0)
{
new message[256];
strmid(message, cmdtext, 4, strlen(cmdtext));
   GetPlayerName(playerid, playername, sizeof(playername));
if(!strlen(message))
{
   SendClientMessage(playerid,COLOR_GRAD1, \" Használat: /try [Akció]\");
}
else
{
   switch(random(2))
   {
      case 1:
      {
         format(string, sizeof(string), \"** %s megpróbál(ja) %s és sikerül neki.\", GetPlayerNameEx(playerid),message);
         ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
           printf(\"%s\", string);
      }
      default:
      {
         format(string, sizeof(string), \"** %s megpróbál(ja) %s de nem sikerül neki.\", GetPlayerNameEx(playerid),message);
         ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
           printf(\"%s\", string);
      }
   }
        }
        return 1;
    }

 
Név nélkül ismeretlenül:
 

if(strcmp(cmd, \"/try\", true) == 0)
{
new message[256];
strmid(message, cmdtext, 4, strlen(cmdtext));
if(!strlen(message))
{
   SendClientMessage(playerid,COLOR_GRAD1, \" Használat: /try [Akció]\");
}
else
{
   switch(random(2))
   {
      case 1:
      {
         format(string, sizeof(string), \"** Valaki megpróbál(ja) %s, és sikerül neki.\", message);
         ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
           printf(\"%s\", string);
      }
      default:
      {
         format(string, sizeof(string), \"** Valaki megpróbál(ja) %s, de nem sikerül neki.\", message);
         ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
           printf(\"%s\", string);
      }
   }
        }
        return 1;
    }

 
Tudom hogy nem nagy munka, de a tapasztaltabbak kérlek ne szidjanak le, én csak segíteni akarok azoknak akik rászorulnak.
Illetve szükséged van erre a kódra ahhoz hogy ne legyen alsócsík a névben:
 

stock GetPlayerNameEx(playerid)
{
    new string[24];
    GetPlayerName(playerid,string,24);
    new str[24];
    strmid(str,string,0,strlen(string),24);
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if (str == \'_\') str = \' \';
    }
    return str;
}

 
Ahhoz hogy csak egy bizonyos területen belül lássák kell ez:
 

forward ProxDetector(Float:radi, playerid, str[], col1, col2, col3, col4, col5);
public ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new i = 0; i < MAX_PLAYERS; i++)
{
   if(IsPlayerConnected(i))
   {
      GetPlayerPos(i, posx, posy, posz);
      tempposx = (oldposx -posx);
      tempposy = (oldposy -posy);
      tempposz = (oldposz -posz);
      if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
      {
      SendClientMessage(i, col1, str);
      }
      else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
      {
      SendClientMessage(i, col2, str);
      }
      else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
      {
      SendClientMessage(i, col3, str);
      }
      else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
      {
      SendClientMessage(i, col4, str);
      }
      else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
      {
      SendClientMessage(i, col5, str);
      }
   }
}
}
return 1;
}
« Utoljára szerkesztve: 2011. November 22. - 19:48:35 írta APC »

Nem elérhető Zharko

  • 1955
  • Future House <3
    • Profil megtekintése
Megpróbálás
« Válasz #1 Dátum: 2010. Április 05. - 15:29:57 »
0 Show voters
Grat, de ez nélkül nem muködik: :D
 
forward ProxDetector(Float:radi, playerid, str[], col1, col2, col3, col4, col5);
public ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new i = 0; i < MAX_PLAYERS; i++)
{
   if(IsPlayerConnected(i))
   {
      GetPlayerPos(i, posx, posy, posz);
      tempposx = (oldposx -posx);
      tempposy = (oldposy -posy);
      tempposz = (oldposz -posz);
      if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
      {
      SendClientMessage(i, col1, str);
      }
      else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
      {
      SendClientMessage(i, col2, str);
      }
      else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
      {
      SendClientMessage(i, col3, str);
      }
      else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
      {
      SendClientMessage(i, col4, str);
      }
      else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
      {
      SendClientMessage(i, col5, str);
      }
   }
}
}
return 1;
}

Nem elérhető SnicK

  • 7521
    • Profil megtekintése
Megpróbálás
« Válasz #2 Dátum: 2010. Április 05. - 15:30:54 »
0 Show voters
Mint írtam gfbe elég simán bemásolni ott van ProxDetector :)
De a tökéletesség igénye miatt berakom ezt is.
UPDATE: Mostmár nincsen alsócsík a név közt!

Nem elérhető ZeRo

  • 4620
  • Ex Globális Moderátor
    • Profil megtekintése
Megpróbálás
« Válasz #3 Dátum: 2010. Április 05. - 16:15:06 »
0 Show voters
Idézetet írta: SnicK date=1270471997\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"1248\" data-ipsquote-contentclass=\"forums_Topic


stock GetPlayerNameEx(playerid)
{
    new string[24];
    GetPlayerName(playerid,string,24);
    new str[24];
    strmid(str,string,0,strlen(string),24);
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if (str == \'_\') str = \' \';
    }
    return str;
}

 

Jó lett, de ennél a függvénynél kicsit túlbonyolítottad, mivel nem kell egy új sztringet létrehozni, elég, ha azt formázod, amiben a játékos neve van. A másik dolog meg az, hogy a ciklust feleslegesen futtatod 24 - szer, hogyha rövidebb a neve a játékosnak( és szerintem olyan gyakrabban van  :angel: ).
 

GetPlayerNameEx( playerid ) {
    new str[ MAX_PLAYER_NAME ];
    GetPlayerName( playerid, str, sizeof str );
    for( new x = 0; x < strlen( str ); ++x ) {
        if( str[ x ] == \'_\' ) str[ x ] = \' \';
    }
    return str;
}

 
Kérlek ne vedd belekötésnek.  :neutral:

Nem elérhető SnicK

  • 7521
    • Profil megtekintése
Megpróbálás
« Válasz #4 Dátum: 2010. Április 05. - 16:28:13 »
0 Show voters
Semmi gond köszönöm a segitséget :)

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal