02.07.2017, 10:55
Hello,
I have the command /fetch which works with the player ID, as well as name.
I have the command /god, which only works with the player ID, but not name.
Question: How can I allow /god to work with player ID and name?
/fetch
/god
Many thanks.
I have the command /fetch which works with the player ID, as well as name.
I have the command /god, which only works with the player ID, but not name.
Question: How can I allow /god to work with player ID and name?
/fetch
Code:
CMD:fetch(playerid, params[]) { if(PlayerInfo[playerid][Level] < 3) return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command"); new player1, string[128]; if(sscanf(params, "u", player1)) return SendClientMessage(playerid, red, "USAGE: /fetch [playerid]"); if(player1 == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "ERROR: Player is not connected"); if(player1 == playerid) return SendClientMessage(playerid, red, "ERROR: You cannot use this command on yourself"); if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin"); CMDMessageToAdmins(playerid, "FETCH"); new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); SetPlayerInterior(player1, GetPlayerInterior(playerid)); SetPlayerVirtualWorld(player1, GetPlayerVirtualWorld(playerid)); if(GetPlayerState(player1) == 2) { new VehicleID = GetPlayerVehicleID(player1); SetVehiclePos(VehicleID, x+3, y, z); LinkVehicleToInterior(VehicleID, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(GetPlayerVehicleID(player1), GetPlayerVirtualWorld(playerid)); } else SetPlayerPos(player1, x+2, y, z); format(string, sizeof(string), "You have been fetched to Administrator %s's location", pName(playerid)); SendClientMessage(player1, green, string); format(string, sizeof(string), "You have fetched %s to your location", pName(player1)); SendClientMessage(playerid, orange, string); return 1; }
Code:
CMD:god(playerid, params[]) { if(PlayerInfo[playerid][Level] < 4 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command"); new player1, string[128]; new giveplayerid; if(sscanf(params, "i", giveplayerid)) return SendClientMessage(playerid, red, "USAGE: /god [playerid]"); if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, red, "ERROR: Player is not connected"); switch(PlayerInfo[giveplayerid][God]) { case 0: { PlayerInfo[giveplayerid][God] = 1; PlayerInfo[giveplayerid][GodCar] = 1; SetPlayerHealth(giveplayerid, 100000); format(string, sizeof(string), "Godmode has been enabled", pName(player1)); SendClientMessage(playerid, green, string); CMDMessageToAdmins(giveplayerid, "GOD"); } case 1: { ResetPlayerWeapons(giveplayerid); PlayerInfo[giveplayerid][God] = 0; PlayerInfo[giveplayerid][GodCar] = 0; format(string, sizeof(string), "Godmode has been disabled", pName(player1)); SendClientMessage(playerid, red, string); SetPlayerHealth(giveplayerid, 100); } } return 1; }