Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define X 0.0
- #define Y 0.0
- #define Z 0.0
- new bool:Guerra;
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new Tick, tmp[256], idx, cmd[256];
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmd, "/declararguerra", true) == 0)
- {
- new id, str[128];
- tmp = strtok(cmdtext,idx);
- id = strval(tmp);
- if(Guerra == true) return SendClientMessage(playerid,-1,"Já está ocorrendo uma guerra.");
- if(GetTickCount() - Tick < 60000) return SendClientMessage(playerid,-1,"Aguarde 2 minutos para declarar guerra novamente.");
- if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USO: /declararguerra [ID]");
- if(GetPVarInt(playerid, "Guerra") == 1) return SendClientMessage(playerid, -1, "Você já está em uma guerra.");
- if(GetPVarInt(id, "Guerra") == 1) return SendClientMessage(playerid, -1, "O jogador já está em uma guerra.");
- if(id == playerid) return SendClientMessage(playerid, -1,"Você não pode declarar guerra a você mesmo.");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1,"Jogador Invalido.");
- format(str, sizeof(str), "Você declarou guerra ao ID %d. Aguarde até que ele aceite.", id);
- SendClientMessage(playerid, -1, str);
- format(str, sizeof(str), "O ID %d declarou guerra à você. Para aceitar digite /aceitar, para recusar digite /recusar.", playerid);
- SendClientMessage(playerid, -1, str);
- SetPVarInt(playerid, "Guerra", 1);
- SetPVarInt(id, "Guerra", 1);
- SetPVarInt(id, "User", playerid);
- Tick = GetTickCount();
- return 1;
- }
- if(strcmp(cmd, "/recusar", true) == 0)
- {
- if(GetPVarInt(playerid, "Guerra") == 0) return SendClientMessage(playerid, -1, "Você não está em guerra alguma !");
- SendClientMessage(playerid, -1, "Você recusou o pedido de guerra.");
- SendClientMessage(GetPVarInt(playerid, "User"), -1, "Seu pedido de guerra foi recusado.");
- SetPVarInt(playerid, "Guerra", 0);
- SetPVarInt(GetPVarInt(playerid, "User"), "Guerra", 0);
- DeletePVar(playerid, "User");
- return 1;
- }
- if(strcmp(cmd, "/aceitar", true) == 0)
- {
- new n[MAX_PLAYER_NAME],n2[MAX_PLAYER_NAME], str[128];
- if(GetPVarInt(playerid, "Guerra") == 0) return SendClientMessage(playerid, -1, "Você não está em guerra alguma !");
- if(GetPVarInt(playerid, "Guerra") == 2) return SendClientMessage(playerid, -1, "Você já está em uma guerra.");
- SendClientMessage(playerid, -1, "Você aceitou o pedido de guerra e foi teleportado.");
- SendClientMessage(GetPVarInt(playerid, "User"), -1, "Seu pedido de guerra foi aceito e você foi teleportado.");
- SetPlayerPos(GetPVarInt(playerid, "User"), X, Y, Z);
- SetPlayerPos(playerid, X, Y, Z);
- SetPVarInt(GetPVarInt(playerid, "User"), "Guerra", 2);
- SetPVarInt(GetPVarInt(playerid, "User"), "User", playerid);
- SetPVarInt(playerid, "Guerra", 2);
- GetPlayerName(playerid, n, sizeof(n));
- GetPlayerName(GetPVarInt(playerid, "User"), n2, sizeof(n2));
- format(str, sizeof(str),"%s e %s entraram numa guerra.");
- SendClientMessageToAll(-1, str);
- Guerra = true;
- return 1;
- }
- return 0;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(Guerra == true)
- {
- if(GetPVarInt(playerid,"Guerra") == 2)
- {
- new n[MAX_PLAYER_NAME], n2[MAX_PLAYER_NAME], str[128];
- GetPlayerName(GetPVarInt(playerid, "User"), n, sizeof(n));
- GetPlayerName(playerid, n2, sizeof(n2));
- format(str, sizeof(str), "%s matou %s em uma guerra !");
- SendClientMessageToAll(-1,str);
- GivePlayerMoney(playerid, -5000);
- GivePlayerMoney(GetPVarInt(playerid, "User"), 5000);
- SendClientMessage(playerid, -1,"Você morreu na guerra e por isso perdeu 5000.");
- SendClientMessage(GetPVarInt(playerid, "User"), -1,"Você venceu a guerra e por isso ganhou 5000.");
- SpawnPlayer(GetPVarInt(playerid, "User"));
- Guerra = false;
- SetPVarInt(playerid,"Guerra", 0);
- SetPVarInt(GetPVarInt(playerid, "User"),"Guerra", 0);
- DeletePVar(GetPVarInt(playerid, "User"), "User");
- DeletePVar(playerid,"User");
- return 1;
- }
- return 1;
- }
- return 1;
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment