[Pomoc] Komanda za oruzje

Započeo Matteo, Septembar 20, 2010, 15:23:04 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Evo kao sto vidite u terba mi najobicnija komanda za davanje oruzja nekoj osobi ne sebo ko ovdje
if (strcmp("/givesniper", cmdtext, true, 10) == 0)
{
GivePlayerWeapon(playerid, 34, 40);
return 1;
}

Hocu da mogu dat nekome... Pomoc...

if(strcmp(cmd, "/givegun", true) == 0)
{
   if(IsPlayerConnected(playerid))
   {
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /givegun [playerid/PartOfName] [weaponid(eg. 46 = Parachute)] [ammo]");
return 1;
}
new playa;
new gun;
new ammo;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
gun = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /givegun [playerid/PartOfName] [weaponid] [ammo]");
SendClientMessage(playerid, COLOR_GRAD4, "3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 10-13(Dildo) 14(Flowers) 16(Grenades) 18(Molotovs) 22(Pistol) 23(SPistol)");
SendClientMessage(playerid, COLOR_GRAD3, "24(Eagle) 25(shotgun) 29(MP5) 30(AK47) 31(M4) 33(Rifle) 34(Sniper) 37(Flamethrower) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
return 1;
}
if(gun < 1||gun > 46||gun==27)
{ SendClientMessage(playerid, COLOR_GRAD1, "   wrong WeaponID!"); return 1; }
tmp = strtok(cmdtext, idx);
ammo = strval(tmp);
if(ammo <1||ammo > 999)
{ SendClientMessage(playerid, COLOR_GRAD1, "   dont go below 1 or above 999 bullets!"); return 1; }
if (PlayerInfo[playerid][pAdmin] >= 4)
{
   if(IsPlayerConnected(playa))
   {
       if(playa != INVALID_PLAYER_ID)
       {
GivePlayerWeapon(playa, gun, ammo);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
}
}
return 1;
}

ja msm da je toto
Poslednja Izmena: Septembar 20, 2010, 15:26:24 POSLE PODNE od gonss


//----------------------------------[GiveGun]------------------------------------------------
if(strcmp(cmd, "/givegun", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /givegun [playerid/PartOfName] [weaponid(eg. 46 = Parachute)] [ammo]");
return 1;
}
new playa;
new gun;
new ammo;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
gun = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /givegun [playerid/PartOfName] [weaponid] [ammo]");
SendClientMessage(playerid, COLOR_GRAD4, "3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 10-13(Dildo) 14(Flowers) 16(Grenades) 18(Molotovs) 22(Pistol) 23(SPistol)");
SendClientMessage(playerid, COLOR_GRAD3, "24(Eagle) 25(shotgun) 29(MP5) 30(AK47) 31(M4) 33(Rifle) 34(Sniper) 37(Flamethrower) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
return 1;
}
if(gun < 1||gun > 46||gun==27||gun==1||gun==2||gun==9||gun==17||gun==19||gun==20||gun==21||gun==36||gun==38||gun==39||gun==40||gun==44||gun==45)
{ SendClientMessage(playerid, COLOR_GRAD1, "   wrong WeaponID!"); return 1; }
tmp = strtok(cmdtext, idx);
ammo = strval(tmp);
if(ammo <1||ammo > 999)
{ SendClientMessage(playerid, COLOR_GRAD1, "   dont go below 1 or above 999 bullets!"); return 1; }
if (PlayerInfo[playerid][pAdmin] >= 4)
{
    if(IsPlayerConnected(playa))
    {
        if(playa != INVALID_PLAYER_ID)
        {
GivePlayerWeapon(playa, gun, ammo);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "   Nisi Ovlasten da koristis tu komandu!");
}
}
return 1;
}

to?

da za to mi ispise milju errora, imam svoj gamemod nije nijedan kao GF bas moj, treba mi nesto jednostavno jer je to DM skripta

za DM
//============GiveGun=========================
if(strcmp(cmdtext, "/givegun",true)==0) {
new weaponname[65], player2name[MAX_PLAYER_NAME];
new playermsg[256], player2msg[256];
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_RED, "Usage: /givegun [playerid]");
return 1;
}
new player2id = strval(tmp);

if(IsPlayerConnected(player2id))
{
if(player2id==playerid)
{
SendClientMessage(playerid, COLOR_RED, "You can't use your own ID");
return 1;
}
else
{
weaponid = GetPlayerWeapon(playerid);
new weaponammo;
if(weaponid == 0)
{
SendClientMessage(playerid, COLOR_RED, "You're not holding a weapon");
return 1;
}
else
{
new weapo[13][2];
for(new i;i<13;i++)
{
GetPlayerWeaponData(playerid, i, weapo[i][0], weapo[i][1]);
if(weapo[i][0]==weaponid) weaponammo=weapo[i][1];
}
ResetPlayerWeapons(playerid);
for(new i;i<13;i++) if(weapo[i][0]!=weaponid) GivePlayerWeapon(playerid, weapo[i][0], weapo[i][1]);
GivePlayerWeapon(player2id, weaponid, weaponammo);

GetWeaponName(weaponid, weaponname, 64);
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerName(player2id, player2name, sizeof(player2name));

format(playermsg, 255, "You gave your %s to %s(%d)", weaponname, player2name, player2id);
SendClientMessage(playerid, COLOR_YELLOW, playermsg);

format(player2msg, 255, "You recived a %s from %s(%d)", weaponname, playername, playerid);
SendClientMessage(player2id, COLOR_YELLOW, player2msg);
}
}
}
else
{
format(string, sizeof(string), "(%d) is not an active player", player2id);
SendClientMessage(playerid, COLOR_RED, string);
}
return 1;
}

opet errori daj nes skroz jednostavno, mogu ja svako komadnu za svako oruzje, nije bed samo da ukucam npr /giveminigun [id] i da on to oruzje da nekome
uredite ovo:
if (strcmp("/givesniper", cmdtext, true, 10) == 0)
{
GivePlayerWeapon(playerid, 34, 40);
return 1;
}
Poslednja Izmena: Septembar 20, 2010, 17:52:57 POSLE PODNE od matteokov

Kod give player weapon poslje player id stavis ono ti je id prvo a drugo ammo... I uredis recimo tec9
Playerid,32,100
32-id tec9
100-ammo ...
Nadam se da sam pomogo...
Iam stunt mode al na mobu sam pa nemogu dat.. Sry
Datum registracije:    Listopad 21, 2009, 15:56:43
|Rick Dunn| NaNx |Soldier |
|Maper | Web Developer [HTML+CSS] | C++ beginner |

Respect: Karike, Chris, ///Masic, Stormer, Walter, NeNo, Pacino, NaNek

Evo kako bi to izgledalo preko ZCMD-a i sscanf:


CMD:givegun(playerid, params[])
{
new
    pID,
    gID,
Ammo;
if(sscanf(params, "udd", pID, gID, Ammo)) return SendClientMessage(playerid, 0xFF0000AA, "Koristi: /givegun <ID> <Broj oruzja> <Ammo>");
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, " Taj igrac ne postoji!");
GivePlayerWeapon(pID, gID, Ammo);
return 1;
}

Last nick: Paradox

Citat: [SA]Rick Dunn aka NaNx[NSG] poslato Septembar 20, 2010, 19:35:45 POSLE PODNE
Kod give player weapon poslje player id stavis ono ti je id prvo a drugo ammo... I uredis recimo tec9
Playerid,32,100
32-id tec9
100-ammo ...
Nadam se da sam pomogo...
Iam stunt mode al na mobu sam pa nemogu dat.. Sry

nekuzim bas :/

paradox gdje to ubacim posto je CMD
Poslednja Izmena: Septembar 21, 2010, 14:34:29 POSLE PODNE od matteokov

Mozes ispod OnPlayerCommandText, ali ti treba ZCMD i sscanf.

Last nick: Paradox

moze link od sscanfa
Poslednja Izmena: Septembar 21, 2010, 15:03:56 POSLE PODNE od matteokov



sscanf2.inc stavis u pawno/include folder. Ako imas Windows onda stavi sscanf.dll u plugins folder (ako nemas plugins folder, napravi ga) i onda samo jos u server.cfg stavi plugins sscanf . A ako imas Linux onda stavi sscanf.so u plugins folder i u server.cfg umjesto plugins sscanf stavi plugins sscanf.so . Nadam se da sam dobro objasnio.

Last nick: Paradox