CenterString(string[],size) //Centers a string with spaces (size = length of string) AngleToPoint(x1,y1,x2,y2) //Calculate an angle to a point
TransportVehicleToPlayerByAir(playerid,vehicleid) //Transports the vehicle to the player by air! (Andromada) GetVehicleType(vehicleid) //Returns 0 when its a car, 1 when its a boat and 2 when its a plane GetVehicleSpeed(playerid,UseMPH = 0) //Returns playerspeed (i took it from hiddos's stalkercows, i just tought this was a must-have) GetClosestVehicleForPlayer(playerid) //Returns closest vehicleid GetClosestVehicleFromPoint(x,y,tx,ty) //Returns closest vehicleid PutPlayerInObject(playerid,objectid) //Allows player to DRIVE/FLY a object! (Credits to hiddos for his turtle script) RemovePlayerFromObject(playerid) //Removes player from object IsPlayerInObject(playerid) //Returns 1 when player is flying an object GetPlayerObjectID(playerid) //Returns objectid GetVehicleNameByModelId(modelid) //Returns vehicle name GetWeaponNameById(weaponid) //Returns weaponname ToggleVehicleLights(vehicleid,toggle) //Toggle light on/off AreVehicleLightsOn(vehicleid) //Returns 1 when the lights are on ToggleVehicleAlarm(vehicleid,toggle) //Toggle alarm on/off IsVehicleAlarmOn(vehicleid) //Returns 1 when the alarm is going off SetVehicleToAlarm(vehicleid,time) //Start the vehicle's alarm and turn it off after the ammount of milisecconds you entered GetDistanceBetweenPoints(Float:x,Float:y,Float:tx,Float:ty) //Returns distance between pts
GetWeaponIdByName(weaponname[]) //returns weaponid GetVehicleIdByName(weaponname[]) //returns vehicleid SetVehicleNumberPlateEx(vehicleid,numberplate[]) //will set the vehicle's licenseplate and respawn it at last known location MutePlayer(playerid) //mutes player UnMutePlayer(playerid) //unmutes player JailPlayer(playerid) //jails player UnJailPlayer(playerid) //unjails player SetPlayerToReconnect(playerid) //Will let the player reconnect SetPlayerMoney(playerid,ammount) //Resets and sets the given value of the players money GivePlayerScore(playerid,ammount) //Gives player extra score GetPlayerNameEx(playerid) //Returns name of player GetPlayerIpEx(playerid) //Returns IP of player KickEx(playerid,reason[]) //Kick player with reason SendRconCommandEx(type[],{float,_}:...) //A combination of SendRconCommand & format SendClientMessageEx(playerid,color,type[],{float,_}:...) //A combination of SendClientMessage & format SendClientMessageToAllEx(color,type[],{float,_}:...) //A combination of SendClientMessageToAll & format GameTextForPlayerEx(playerid,time,style,type[],{Float,_}:...) //A combination of GameTextGotPlayer & format GameTextForAllEx(time,style,type[],{Float,_}:...) //A combination of GameTextForAll & format
public OnPlayerConnect(playerid)
{
new string[128],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof pName);
format(string,sizeof string,"Welcome %s",pName);
SendClientMessageToAll(COLOR_GREEN,string);
}
public OnPlayerConnect(playerid)
{
SendClientMessageToAllEx(COLOR_GREEN,"ss","Welcome ",GetPlayerNameEx(playerid));
}
new string[64];
format(string,sizeof string,"kick %i",playerid);
SendRconCommand(string);
SendRconCommandEx("si","kick ",playerid);
SendRconCommandEx(type[],{float,_}:...)
COMMAND:Fly(playerid,params)
{
new object = CreateObject(yourobjectstuff);
PutPlayerInObject(playerid,object);
}
//You also have just like vehicles the GetPlayerObjectId,IsPlayerInObject and RemovePlayerFromObject
COMMAND:weapon(playerid,params[])
{
new weapon = GetWeaponIdByName(params); //converts the weaponname to weaponmodel
if(weapon == -1) return SendClientMessage(playerid,gCOLOR_RED,"Invalid weapon name!");
GivePlayerWeapon(playerid,weapon,100);
return 1;
}
COMMAND:veh(playerid,params[])
{
new vehicle = GetVehicleIdByName(params); //converts the vehiclename to modelID
if(vehicle == -1) return SendClientMessage(playerid,gCOLOR_RED,"Invalid vehicle name!");
new Float:pos[3];GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
AddStaticVehicle(vehicle,pos[0],pos[1],pos[2]);
return 1;
}
COMMAND:changeplate(playerid,params[])
{
new vehicle = GetPlayerVehicleId(playerid);
SetVehicleNumberPlateEx(vehicle,params); //sets the license plate, respawns the vehicle and teleports it back to the player
return 1;
}
COMMAND:mute(playerid,params[])
{
if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
new id,reason[64];
if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /mute [id] [reason]");
sscanf(params,"is[64]",id,reason);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
if(PlayerInfo[id][Muted] == 1) return SendClientMessage(playerid,color_red,"Player is already muted!");
if(!strlen(reason))
{
SendClientMessageToAllEx(color_blue,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} muted ",PlayerInfo[id][Username],".");
} else {
SendClientMessageToAllEx(color_blue,"sssssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} muted ",PlayerInfo[id][Username]," Reason:",reason,".");
}
MutePlayer(id); //mutes the player
return 1;
}
COMMAND:unmute(playerid,params[])
{
if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
new id;
if(sscanf(params,"i",id))return SendClientMessage(playerid,color_red,"USAGE: /unmute [id]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
if(PlayerInfo[id][Muted] == 0) return SendClientMessage(playerid,color_red,"Player is not muted!");
SendClientMessageToAllEx(color_blue,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} unmuted ",PlayerInfo[id][Username],".");
UnMute(id); //unmutes the player
return 1;
}
COMMAND:jail(playerid,params[])
{
if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
new id,reason[64];
if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /jail [id] [reason]");
sscanf(params,"is[64]",id,reason);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
if(!strlen(reason))
{
SendClientMessageToAllEx(color_blue,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} jailed ",PlayerInfo[id][Username],".");
} else {
SendClientMessageToAllEx(color_blue,"sssssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} jailed ",PlayerInfo[id][Username]," Reason:",reason,".");
}
JailPlayer(id); //puts the player in the jail interior, jail position and frozen
return 1;
}
COMMAND:unjail(playerid,params[])
{
if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
new id;
if(sscanf(params,"i",id))return SendClientMessage(playerid,color_red,"USAGE: /unjail [id]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
if(PlayerInfo[id][Jailed] == 0) return SendClientMessage(playerid,color_red,"Player is not jailed!");
SendClientMessageToAllEx(color_blue,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} unjailed ",PlayerInfo[id][Username],".");
//released the player
return 1;
}
COMMAND:iambugged(playerid,params[])
{
SetPlayerToReconnect(playerid);
return 1;
}
COMMAND:setmoney(playerid,params[])
{
if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
new id,value;
if(sscanf(params,"ii",id,value)) return SendClientMessage(playerid,color_red,"USAGE: /setmoney [playerid] [value]");
SetPlayerMoney(id,value); //this instead of new string,GetPlayerMoney, string + ammount, ResetPlayerMoney and then GivePlayerMoney, just saved you 4 lines!
SendClientMessageEx(id,color_green,"sssis","Administrator ",PlayerInfo[playerid][Username]," has changed your money to ",value," !");
SendClientMessageEx(playerid,color_green,"sssis","You have succesfully changed ",PlayerInfo[id][Username],"'s money to ",value," .");
return 1;
}
COMMAND:givescore(playerid,params[])
{
if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
new id,value;
if(sscanf(params,"ii",id,value)) return SendClientMessage(playerid,color_red,"USAGE: /givescore [playerid] [value]");
GivePlayerScore(id,value);
SendClientMessageEx(id,color_green,"sssis","Administrator ",PlayerInfo[playerid][Username]," gave your ",value," extra points!");
SendClientMessageEx(playerid,color_green,"sssis","You gave ",PlayerInfo[id][Username]," ",value," extra score!");
return 1;
}
//Just a shortcut, this will return the player's name instead of storing it into a string (usefull when formatting), example:
new file[64];
format(file,sizeof file,"Users\%s.ini",GetPlayerNameEx(playerid));
//Just a shortcut, this will return the player's IP instead of storing it into a string (usefull when formatting), see GetPlayerNameEx for example
COMMAND:kick(playerid,params[])
{
if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
new id,reason[64];
if(sscanf(params,"is",id,reason)) return SendClientMessage(playerid,color_red,"USAGE: /kick [id] [reason]");
KickEx(id,reason); //kicks player with reason
return 1;
}
//Please check the formatting part , and the original command (wiki.sa-mp.com) to explain how this command works
//Please check the formatting part , and the original command (wiki.sa-mp.com) to explain how this command works
//Please check the formatting part , and the original command (wiki.sa-mp.com) to explain how this command works
//Please check the formatting part , and the original command (wiki.sa-mp.com) to explain how this command works
//Please check the formatting part , and the original command (wiki.sa-mp.com) to explain how this command works
gCOLOR_RED gCOLOR_GREEN gCOLOR_BLUE gCOLOR_YELLOW gCOLOR_ORANGE gCOLOR_GRAY gCOLOR_BLACK gCOLOR_MAGENTA gCOLOR_DARKRED gCOLOR_DARKGREEN gCOLOR_DARKBLUE
1.1/1.1b: Some warnings are fixed 1.2: -All warnings should be fixed now -gCOLOR_ORANGE added 2.0: -A lot of new commands added 2.1: -Include is no more blocking OnPlayerDisconnect, and 2 new functions has been added: CenterString(string[],size) AngleToPoint(x1,y1,x2,y2)
I'm wondering why you didn't use one of the standard ways of doing advanced formatting? There has been functions for things like your "SendClientMessageEx" function for years which incorporate "format" and "SendClientMessage". The advantage of that method is the use of formats such as "%.2f" etc, which this way doesn't support.
Otherwise a nice range of convenience functions. |