Korisne skripte i kodovi

Započeo matejdz, Maj 05, 2009, 12:15:21 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 4 gostiju pregledaju ovu temu.

E kad bi ja znao da skriptam,,, :(...vi stavljate te kodove tu a ja buljim ko budala i ne znam sta je to jel moze neko da me nauci da skriptujem samo me pm. ;D

ScorpioN

Imaš tu hrpu tutorijala a svi su ti na hrvatskom,pa ćeš razumjet.
Ako imaš volje pregledavaj ovaj forum i pitaj nešto u vezi skriptanja ako te zanima,ali nemoj više molit da te netko
nauči skriptat,jer smo svi mi isto naučili samo tako što smo pregledavali tutorijale i malo po malo naučili nešto,dakako
da će ti trebati dosta vremena,ali samo uči.

Trawis

evo ja sam napravio neku sitnicu,nije nesto al dobro doÄ'e  :P
Opis:Upisom komande unistava vozilo u koje sjednete
nadam se da je korisno
if(strcmp(cmd, "/unistiv", true) == 0)
{
   if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 1338)
   {
    if(IsPlayerInAnyVehicle(playerid))
                        {
                        new veh = GetPlayerVehicleID(playerid);
        DestroyVehicle(veh);
        }
        else
        {
        SendClientMessage(playerid,COLOR_RED,"Nisi u vozilu");
        }
}
else
{
SendClientMessage(playerid,COLOR_RED,"Samo 1338");
}
return 1;
}

Poslednja Izmena: Avgust 10, 2009, 22:07:23 POSLE PODNE od [EF]Trawis

 Interior Busa ;)

stavim screenshot dok uslikam...ne da mi se sada..:D





#include <a_samp>

new IsInBus[MAX_PLAYERS];
new Timer1[MAX_PLAYERS];
new Timer2[MAX_PLAYERS];
new Timer3[MAX_PLAYERS];

public OnFilterScriptInit()
{
print("  ===== Interior Busa by Me ;) =======");

    CreateObject(2631, 2022.0, 2236.7, 2102.9, 0.0, 0.0, 90.0);
CreateObject(2631, 2022.0, 2240.6, 2102.9, 0.0, 0.0, 90.0);
CreateObject(2631, 2022.0, 2244.5, 2102.9, 0.0, 0.0, 90.0);
CreateObject(2631, 2022.0, 2248.4, 2102.9, 0.0, 0.0, 90.0);
CreateObject(16501, 2022.1, 2238.3, 2102.8, 0.0, 90.0, 0.0);
CreateObject(16501, 2022.1, 2245.3, 2102.8, 0.0, 90.0, 0.0);
CreateObject(16000, 2024.2, 2240.1, 2101.2, 0.0, 0.0, 90.0);
CreateObject(16000, 2019.8, 2240.6, 2101.2, 0.0, 0.0, -90.0);
CreateObject(16000, 2022.2, 2248.7, 2101.2, 0.0, 0.0, 180.0);
CreateObject(16501, 2021.8, 2246.5, 2107.3, 0.0, 270.0, 90.0);
CreateObject(16501, 2022.0, 2240.8, 2107.3, 0.0, 270.0, 0.0);
CreateObject(16501, 2022.0, 2233.7, 2107.3, 0.0, 270.0, 0.0);
CreateObject(18098, 2024.3, 2239.6, 2104.8, 0.0, 0.0, 90.0);
CreateObject(18098, 2024.3, 2239.7, 2104.7, 0.0, 0.0, 450.0);
CreateObject(18098, 2020.1, 2239.6, 2104.8, 0.0, 0.0, 90.0);
CreateObject(18098, 2020.0, 2239.6, 2104.7, 0.0, 0.0, 90.0);
CreateObject(2180, 2023.6, 2236.1, 2106.7, 0.0, 180.0, 90.0);
CreateObject(2180, 2023.6, 2238.1, 2106.7, 0.0, 180.0, 90.0);
CreateObject(2180, 2023.6, 2240.1, 2106.7, 0.0, 180.0, 90.0);
CreateObject(2180, 2023.6, 2242.1, 2106.7, 0.0, 180.0, 90.0);
CreateObject(2180, 2023.6, 2244.1, 2106.7, 0.0, 180.0, 90.0);
CreateObject(2180, 2023.6, 2246.1, 2106.7, 0.0, 180.0, 90.0);
CreateObject(2180, 2023.6, 2248.1, 2106.7, 0.0, 180.0, 90.0);
CreateObject(2180, 2020.3, 2235.1, 2106.7, 0.0, 180.0, 270.0);
CreateObject(2180, 2020.3, 2237.1, 2106.7, 0.0, 180.0, 270.0);
CreateObject(2180, 2020.3, 2239.1, 2106.7, 0.0, 180.0, 270.0);
CreateObject(2180, 2020.3, 2241.1, 2106.7, 0.0, 180.0, 270.0);
CreateObject(2180, 2020.3, 2243.1, 2106.7, 0.0, 180.0, 270.0);
CreateObject(2180, 2020.3, 2245.1, 2106.7, 0.0, 180.0, 270.0);
CreateObject(2674, 2023.4, 2238.3, 2102.9, 0.0, 0.0, 600.0);
CreateObject(2674, 2020.4, 2242.3, 2102.9, 0.0, 0.0, 600.0);
CreateObject(2674, 2023.4, 2246.3, 2102.9, 0.0, 0.0, 600.0);
CreateObject(14405, 2022.0, 2242.1, 2103.5, 0.0, 0.0, 540.0);
CreateObject(14405, 2022.0, 2243.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2022.0, 2245.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2022.0, 2246.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2022.0, 2248.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2022.0, 2249.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2022.0, 2251.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2024.6, 2242.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2024.6, 2243.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2024.6, 2245.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2024.6, 2246.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2024.6, 2248.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2024.6, 2249.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2024.6, 2251.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2019.4, 2242.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2019.4, 2243.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2019.4, 2245.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2019.4, 2246.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2019.4, 2248.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2019.4, 2249.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2019.4, 2251.1, 2103.5, 0.0, 0.0, 180.0);
CreateObject(14405, 2022.0, 2253.6, 2104.0, -6.0, 0.0, 180.0);
CreateObject(14405, 2021.1, 2253.6, 2104.0, -6.0, 0.0, 180.0);
CreateObject(14405, 2024.6, 2253.6, 2103.5, 0.0, 0.0, 180.0);
CreateObject(2674, 2020.4, 2235.7, 2102.9, 0.0, 0.0, 52.0);
CreateObject(2673, 2020.4, 2246.7, 2102.9, 0.0, 0.0, 270.0);
CreateObject(2700, 2023.5, 2235.1, 2105.5, 180.0, -4.0, 90.0);
CreateObject(2700, 2020.4, 2235.1, 2105.5, 180.0, 0.0, 90.0);
CreateObject(2700, 2023.5, 2242.1, 2105.5, 180.0, -4.0, 90.0);
CreateObject(2700, 2020.4, 2242.1, 2105.5, 180.0, 0.0, 90.0);
CreateObject(1799, 2023.1, 2234.2, 2105.7, 270.0, 0.0, 360.0);
CreateObject(1799, 2019.8, 2234.2, 2105.7, 270.0, 0.0, 0.0);
CreateObject(1538, 2022.7, 2234.7, 2102.8, 0.0, 0.0, 180.0);
CreateObject(1799, 2022.1, 2234.2, 2106.1, 720.0, 90.0, 450.0);
CreateObject(1799, 2021.8, 2234.2, 2105.1, 0.0, 270.0, 270.0);
CreateObject(1799, 2022.1, 2234.2, 2107.3, 0.0, 90.0, 90.0);
CreateObject(1799, 2021.6, 2234.2, 2106.3, 0.0, 270.0, 270.0);
CreateObject(1799, 2022.3, 2234.2, 2104.3, 90.0, 0.0, 180.0);

return 1;
}

public OnFilterScriptExit()
{
print("  ==== Interior Busa Pokrenut ======");

return 1;
}

public OnPlayerConnect(playerid)
{
IsInBus[playerid] = 0;
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_PASSENGER)
{
    if (GetVehicleModel(vehicleid) == 431 || GetVehicleModel(vehicleid) == 437)
    {
            SetPlayerPos(playerid, 2022.0273, 2235.2402, 2103.9536);
            SetPlayerTime(playerid, 00,00);
SetPlayerFacingAngle(playerid, 0);
            SetCameraBehindPlayer(playerid);
            SetPlayerInterior(playerid, 1);
            Timer1[playerid] = SetTimerEx("HornA", 60000, 1, "i", playerid);
            Timer2[playerid] = SetTimerEx("HornB", 60500, 1, "i", playerid);
            Timer3[playerid] = SetTimerEx("STime", 60000, 1, "i", playerid);
        IsInBus[playerid] = vehicleid;
    }
}
return 1;
}

forward HornA(playerid);
forward HornB(playerid);
forward STime(playerid);

public HornA(playerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
PlayerPlaySound(playerid, 1147, X, Y, Z);
}

public HornB(playerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
PlayerPlaySound(playerid, 1147, X, Y+5, Z);
}

public STime(playerid)
{
SetPlayerTime(playerid, 00,00);
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == 16 && IsInBus[playerid] > 0)
{
new Float:X,Float:Y,Float:Z;
GetVehiclePos(IsInBus[playerid], X, Y, Z);
SetPlayerPos(playerid, X+4, Y, Z);
SetPlayerInterior(playerid, 0);
KillTimer(Timer1[playerid]);
KillTimer(Timer2[playerid]);
IsInBus[playerid] = 0;
}
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/gotobus", cmdtext, true, 8) == 0)
{
    if(IsPlayerAdmin(playerid))
    {
      SetPlayerPos(playerid, 2022.0273, 2235.2402, 2103.9536);
  SetPlayerFacingAngle(playerid, 0);
        SetCameraBehindPlayer(playerid);
            SetPlayerInterior(playerid, 1);
        }
        else return 0;
return 1;
}
return 0;
}

public OnPlayerDeath(playerid, killerid, reason)
{
if(IsInBus[playerid] == 1)
{
IsInBus[playerid] = 0;
  KillTimer(Timer1[playerid]);
KillTimer(Timer2[playerid]);
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
IsInBus[playerid] = 0;
return 1;
}

to je fs a ne koristan kod ili skripta -.-




matejdz


ovo je za gf i peno mod
ova vam komanda sluzi da sami izadete iz neke org ako zelite nemorate vise zicati ad ili lidera da vas izbaci  ;D

if(strcmp(cmd, "/otkaz", true) == 0)
{
   if(IsPlayerConnected(playerid))
       {
  if(PlayerInfo[playerid][pMember] != 0)
  {
      GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
      SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Izasao si iz organizacije i sad si civil.");
      gTeam[playerid] = 3;
      PlayerInfo[playerid][pLeader] = 0;
      PlayerInfo[playerid][pTeam] = 3;
      PlayerInfo[playerid][pMember] = 0;
      PlayerInfo[playerid][pRank] = 0;
      PlayerInfo[playerid][pChar] = 0;
      PlayerInfo[playerid][pFMember] = 255;
      SpawnPlayer(playerid);
      new rand = random(sizeof(CIV));
      SetSpawnInfo(playerid, gTeam[playerid], CIV[rand],0.0,0.0,0.0,0,0,0,0,0,0,0);
      PlayerInfo[playerid][pModel] = CIV[rand];
      MedicBill[playerid] = 0;
      return 1;
      }
      else if(PlayerInfo[playerid][pMember] == 0)
      {
          SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Ne mozes dati otkaz kad nisi u nikakoj organizaci.");
          return 1;
          }
       }
}

Poslednja Izmena: Avgust 16, 2009, 23:36:45 POSLE PODNE od Bugs_Bunny
LG ip- 188.40.57.132:7704
uskoro i rpg

Chrome

Eto:

Umjesto da imate onaj bezvezni generator u GF-u(ide na max 9999 kolko se sjecam;) napravio sam si sljedece pa sam mislio da ce nekom dobro doc:

stock generatePhone(playerid)
{
new
        phone[9],
        phoneFinal[9];

for(new i=0;i<9;i++)
phone[i] = random(9);

format(phoneFinal, 9, "%d%d%d%d%d%d%d%d%d", phone[0], phone[1], phone[2], phone[3], phone[4], phone[5], phone[6], phone[7], phone[8]);
        if(PlayerInfo[playerid][PhoneNumber] == strval(phoneFinal)
            generatePhone(playerid);
return strval(phoneFinal);
}

Mozete si naravno staviti da ne dira prva 3 broja nego da stavit nesto poput 098 ili tako nesto  ;)
ovdje kao sto vidite ima jako puno kombinacija tj. brojeva pa se ne trebate bojati da ce imati isti; btw. jos nesto:
ovaj check sam ubacio jer znam da skoro svi koristite GF(nisam siguran da je PhoneNumber varijabla al to lako promijeniti)..

i jos sljedece:


stock getDataTypeFromString(strTarget[])
{
new
int__,
point__,
j = strlen(strTarget);

for(new i; i < j; i++)
{
if(strTarget[i] >= '0' && strTarget[i] <= '9')
int__++;
else if((strTarget[i] == '.'))
    point__++;
}
if((int__) == (j))
    return strval(strTarget);
else if(((int__)+(point__))==(j))
return floatstr(strTarget);
else
    return strTarget;
}


Pojasnjenje: mozete saznati vrstu podataka u stringu i odmah se pretvori u tu vrstu; princip => ako je 'cijeli broj' onda su svi znakovi brojevi; ako su svi brojevi i 1 točka onda je 'racionalni broj' ,a ako nije niti jedno niti drugo mora biti string  ;)

i jos jedno:


stock AssignXYZToInterior(interior, int_multi = 1, &Float: exit_x, &Float: exit_y, &Float: exit_z)
{
switch(interior)
{
    case 3:
    {
        switch(int_multi)
        {
            case 1:
            {
    exit_x = 235.508994;
    exit_y = 1189.169897;
    exit_z = 1080.339966;
}
case 2:
{
    exit_x = 2496.65;
    exit_y = -1696.55;
    exit_z = 1014.74;
}
}
}
case 2:
{
    exit_x = 225.756989;
    exit_y = 1240.000000;
    exit_z = 1082.149902;
}
case 1:
{
    exit_x = 223.043991;
    exit_y = 1289.259888;
    exit_z = 1082.199951;
}
case 7:
{
    exit_x = 225.630997;
    exit_y = 1022.479980;
    exit_z = 1084.069946;
}
case 15:
{
switch(int_multi)
    {
        case 1:
        {
exit_x = 295.138977;
exit_y = 1474.469971;
exit_z = 1080.519897;
}
case 2:
{
    exit_x = 328.493988;
    exit_y = 1480.589966;
    exit_z = 1084.449951;
}
case 3:
{
    exit_x = 385.803986;
    exit_y = 1471.769897;
    exit_z = 1080.209961;
}
}
}
case 9:
{
    switch(int_multi)
    {
        case 1:
        {
    exit_x = 2251.85;
    exit_y = -1138.16;
    exit_z = 1050.63;
}
case 2:
{
exit_x = 2365.42;
exit_y = -1131.85;
exit_z = 1050.88;
}
}
}
case 10:
{
    switch(int_multi)
    {
        case 1:
        {
        exit_x = 2260.76;
        exit_y = -1210.45;
        exit_z = 1049.02;
}
case 2:
{
exit_x = 2262.83;
exit_y = -1137.71;
exit_z = 1050.63;
    }
}
}
case 5:
{
    exit_x = 1299.14;
    exit_y = -794.77;
    exit_z = 1084.00;
}
case 6:
{
    exit_x = -2240.00;
    exit_y = 131.00;
    exit_z = 1035.40;
}
case 12:
{
exit_x = 2324.33;
exit_y = -1144.79;
exit_z = 1050.71;
}
}
}


Cemu ovo sluzi ? Kod pravljenja house sistema ne treba pitati korisnika za exit x,y,z koridnate; i jos se moze koristit gdje trebate xyz izlaza u interioru; int_multi sam stavio jer ima par mjesta gdje ima 3 mjesta u istoj kuci ako me kuzite; default je da ide na 1.. i ovo su interiori samo od safe house-ova stavljeni ;)

have fun  ;)

-ne stavljaj više ovakvu kodu u ovaj topik-
Poslednja Izmena: Avgust 22, 2009, 19:10:39 POSLE PODNE od Don Correlli

i ti si sad faca?treba ti ban zalijepit radi glupiranja...
Poslednja Izmena: Novembar 05, 2009, 17:12:02 POSLE PODNE od dinkO14

Correlli

Citat: mikec poslato Avgust 22, 2009, 18:12:57 POSLE PODNE
OVO JE VEOMA KORISNO !!!!!!   :D  :laugh:  

Evo ti jedno upozorenje od mene, prestani sa time jer nije smiješno. Ovo je topik za korisne skripte i kodove, a ne za smeće.
Poslednja Izmena: Avgust 22, 2009, 18:32:45 POSLE PODNE od Don Correlli

obrisite njegov post zato sto neko stvarno to moze da stavi (neko ko nezna)

i da...
@mikec promeni sig zato sto je potpuno glup

Citat: mikec poslato Avgust 22, 2009, 19:49:00 POSLE PODNE
Citat: SOaD poslato Avgust 22, 2009, 18:46:55 POSLE PODNE
obrisite njegov post zato sto neko stvarno to moze da stavi (neko ko nezna)

i da...
@mikec promeni sig zato sto je potpuno glup

sta mu fali? :D

nefali mu nista nego ispadas budala...uopce nisu zabavne takve gluposti...iskazi se necim pametnim a ne glupostima

Chrome

eto posto je ona tema zakljucana a bas sam se napiso  :D eto ti komanda:
1.

#define IsToPoint(%0,%1,%2,%3,%4,%5,%6) \
((((%0) - (%3)) * ((%0) - (%3))) + (((%1) - (%4)) * ((%1) - (%4))) + (((%2) - (%5)) * ((%2) - (%5))) <= ((%6) * (%6))) //by y_less
#define STAND_X (xcoord)
#define STAND_Y (ycoord)
#define STAND_Z (zcoord)
#define STAND_GIVE_HP   (+hp)
#define STAND_MONEY_GIVEAWAY (lova)

ycmd(jedi); //ongamemodeinit

Command_(jedi)
{
new
Float: player_x,
Float: player_y,
Float: player_z;

GetPlayerPos(playerid, player_x, player_y, player_z);
if(IsToPoint(player_x,player_y,player_z,STAND_X,STAND_Y,STAND_Z))
{
GetPlayerHealth(playerid, player_hp);
SetPlayerHealth(playerid, player_hp + STAND_GIVE_HP);
GivePlayerMoney(playerid, -STAND_MONEY_GIVEAWAY);
SCM(playerid, COLOR_YELLOW, "nebi ja ovdje jeo cevape -.-");
return 1;
}
else
{
SCM(playerid, COLOR_YELLOW, "Nisi blizu standa njubaro");
}
return 0;
}


2.

#define MAX_IO (128)
ycmd(members);

Command_(members)
{
#pragma unused params
new
output[MAX_IO];

if(!PlayerInfo[playerid][pMember] && !PlayerInfo[playerid][pLeader])
{
SCM(playerid, COLOR_YELLOW, "nisi lider ili clan >.<");
}
else
{
SCM(playerid, COLOR_YELLOW, "Clanovi tvoje org: ");
foreach(Player, i)
{
if( (PlayerInfo[i][pMember] == PlayerInfo[playerid][pMember]) || (PlayerInfo[i][pLeader] == PlayerInfo[playerid][pLeader]))
{
format(output, MAX_IO, "Clan: %s | Rank: %d", GetName(i), PlayerInfo[i][pRank]);
SCM(playerid, COLOR_YELLOW, output);
}
}
SCM(playerid, COLOR_YELLOW, "-- --");
return 1;
}
return 0;   
}


u teoriji bi trebalo radit  :D