simple command, to dcmd, help -
jaksimaksi - 25.01.2011
can someone make a dcmd command from this? please
pawn Код:
new cmd[128],idx;
cmd = strtok(cmdtext, idx);
if(!strcmp("/duel", cmd, true))
{
new id,tmp[3][80],w1,w2,string[128];
tmp[0] = strtok(cmdtext, idx);
tmp[1] = strtok(cmdtext, idx);
tmp[2] = strtok(cmdtext, idx);
id = strval(tmp[0]);
w1 = strval(tmp[1]);
w2 = strval(tmp[2]);
if(InvitedDuel[playerid] == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");
if(UsingArena == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");
if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use Valids Weapons IDs");
if(!strlen(tmp[1]) || !strlen(tmp[2]))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use /duel [id] [wep1] [wep2]");
if(!strlen(tmp[0]))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");
if(id == playerid)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");
if(InvitedDuel[id] == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
new name[24];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
IdDuel[id] = playerid;
wep1[id] = w1;
wep2[id] = w2;
SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
return true;
}
return false;
}
Re: id, gun id -
Sasino97 - 25.01.2011
use strtok
Put it near the end of file
Код:
stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
This at the start of OnPlayerCommandText
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new tmp[256];
new idx;
cmd = strtok(cmdtext,idx);
if(strcmp(cmd, "/pvp", true) == 0)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "");//If the playerid isn't admin (put the message)
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USO: /givegun [playerid] [weapon].");
new playerid2;
playerid2 = strval(tmp);
new tmp2[256];
tmp2 = strtok(cmdtext, idx);
new weapid= strval(tmp2);
new string[256];
new name[MAX_PLAYER_NAME];
new name2[MAX_PLAYER_NAME];
new name3[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
GetPlayerName(playerid2,name2,sizeof(name2));
GetWeaponName(armaid,name3,sizeof(name3));
format(string,sizeof(string),"Admin %s(%d) gave the weapon %s(%d) to player %s(%d).",name,playerid,name3,weapid,name2,playerid2);
print(string);//Print to server_log
format(string,sizeof(string),"Admin %s(%d) gave you the weapon %s(%d).",name,playerid,name3,weapid);
SendClientMessage(playerid2,COLOR_RED,string);
format(string,sizeof(string),"You gave %s(%d) the weapon %s(%d).",name2,playerid2,name3,weapid);
SendClientMessage(playerid,COLOR_RED,string);
GivePlayerWeapon(playerid2,weapid,50000);//Unlimited ammo.(if u dont want it change 50000).
return 1;
}
}
Re: id, gun id -
jaksimaksi - 25.01.2011
i get lots of undefinded errors, can somebody add weapon script please?
here is my script:
pawn Код:
new idx;
new ids;
new tmp[128];
new string[128];
tmp = otherplayerids(params, idx);
ids = strval(tmp);
dcmd_pvp(playerid,params[])
{
new tmp[128];
new string[128];
tmp = otherplayerids(params, idx);
id = strval(tmp);
if(InvitedDuel[playerid] == true) return SendClientMessage(playerid,0xF41917AA,"»»[DUELO]«« : Voce^ Ja' Convidou alguйm,Aguarde Expirar o Convite");
if(ArenaUsada == true) return SendClientMessage(playerid,0xF41917AA,"»»[DUELO]«« : No momento a Arena esta' Sendo Usada");
if(!strlen(tmp)) return SendClientMessage(playerid,0xF41917AA,"»»[DUELO]«« : Voce^ deve digitar os ID do Player seguindo a Maneira (/duelo-run [playerid])");
if(id == playerid) return SendClientMessage(playerid,0xF41917AA,"»»[DUELO]«« : Voce^ na~o pode convidar a Si-Mesmo");
if(InvitedDuel[id] == true) return SendClientMessage(playerid,0xF41917AA,"»»[DUELO]«« : No Momento o Player esta' em um Duelo, Aguarde..");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "»»[DUELO]«« : %s esta lhe convidando para um \n Duelo Leve (Clique Aceitar para Aceitar)",name);
ShowPlayerDialog(id,DIALOG_DUELO,DIALOG_STYLE_MSGBOX,"»»[DUELO]«« :",string,"Aceitar", "Recusar");
GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
InvitedDuel[id] = true;
IdDuel[id] = playerid;
SetTimerEx("LimparDuelo",15000,false,"ii",id,playerid);
return 1;
}
Re: id, gun id -
Sasino97 - 25.01.2011
Sorry I dont know how to use dcmd_
but i can try to help you anyway:
I think you have to add another thing like this:
Код:
new tmp2;
tmp2 = strtok(cmdtext,idx);
new gunid = strval(tmp2);
[...]
Re: id, gun id -
jaksimaksi - 26.01.2011
pawn Код:
new cmd[128],idx;
cmd = strtok(cmdtext, idx);
if(!strcmp("/duel", cmd, true))
{
new id,tmp[3][80],w1,w2,string[128];
tmp[0] = strtok(cmdtext, idx);
tmp[1] = strtok(cmdtext, idx);
tmp[2] = strtok(cmdtext, idx);
id = strval(tmp[0]);
w1 = strval(tmp[1]);
w2 = strval(tmp[2]);
if(InvitedDuel[playerid] == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");
if(UsingArena == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");
if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use Valids Weapons IDs");
if(!strlen(tmp[1]) || !strlen(tmp[2]))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use /duel [id] [wep1] [wep2]");
if(!strlen(tmp[0]))
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");
if(id == playerid)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");
if(InvitedDuel[id] == true)
return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
new name[24];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
IdDuel[id] = playerid;
wep1[id] = w1;
wep2[id] = w2;
SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
return true;
}
return false;
}
Can someone do this command for dcmd? please