07.07.2010, 21:43
Not good at all...
You didn't even post the SetPlayerBlind(playerid,toggle); function...
You didn't even post the SetPlayerBlind(playerid,toggle); function...
stock DoesPlayerHaveAnyWeapon(playerid)
{
new
iWeaponID,
iAmmo;
for(new i =0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, iWeaponID, iAmmo);
if(iWeaponID > 0 && iAmmo > 0)
{
return 1;
}
}
return 0;
}
stock DoesPlayerHaveWeapon(playerid, weaponid, slot)
{
if(weaponid < 0 || weaponid > 50)
return 0;
static iWeaponData[2];
// 0 = weapon
// 1 = ammo
GetPlayerWeaponData(playerid, slot, iWeaponData[0], iWeaponData[1]);
if(iWeaponData[0] == weaponid && iWeaponData[1] > 0)
{
return 1;
}
return 0;
}
stock RemovePlayerWeapon(playerid, iWeaponID)
{
if(iWeaponID < 0 || iWeaponID > 50)
{
return;
}
new
iWeapon[13],
iAmmo[13];
for(new iSlot; iSlot < 13; iSlot++)
{
GetPlayerWeaponData(playerid, iSlot, iWeapon[iSlot], iAmmo[iSlot]);
}
ResetPlayerWeapons(playerid);
for(new iSlot; iSlot < 13; iSlot++)
{
if(iAmmo[iSlot] == 0 || iWeapon[iSlot] == iWeaponID)
continue;
GivePlayerWeapon(playerid, iWeapon[iSlot], iAmmo[iSlot]);
}
}
#include <a_samp> new bool:ShowHitCoords = false; //Set to 'true' to show where the bullet hits. (red ball is the center if the enemy's head) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// stock Float:Distance(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2) { new Float:result = floatsqroot(floatpower(floatsub(x2,x1),2)+floatpower(floatsub(y2,y1),2)+floatpower(floatsub(z2,z1),2)); return result; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(newkeys == 132 && GetPlayerWeapon(playerid) == 34) { new Float:Cvx, Float:Cvy, Float:Cvz; new Float:Cvx2, Float:Cvy2, Float:Cvz2; new Float:distance; new Float:P2x, Float:P2y, Float: P2z; new Float:Cx, Float:Cy, Float:Cz; GetPlayerCameraPos(playerid, Cx, Cy, Cz); GetPlayerCameraFrontVector(playerid, Cvx, Cvy, Cvz); for(new i; i<MAX_PLAYERS; i++) { if((IsPlayerConnected(i) && i != playerid)) { GetPlayerPos(i, P2x, P2y, P2z); if(GetPlayerSpecialAction(i) == SPECIAL_ACTION_DUCK) { new Float:P2a; GetPlayerFacingAngle(i, P2a); P2a += 330; P2x += 0.27 * floatsin(-P2a, degrees); P2y += 0.27 * floatcos(-P2a, degrees); P2z -= 0.08; } else P2z += 0.76; distance = Distance(Cx, Cy, Cz, P2x, P2y, P2z); Cvx2 = Cvx * distance + Cx; Cvy2 = Cvy * distance + Cy; Cvz2 = Cvz * distance + Cz; if(ShowHitCoords == true) { CreateObject(2996, Cvx2, Cvy2, Cvz2, 0.0, 0.0, 0.0); CreateObject(2997, P2x, P2y, P2z, 0.0, 0.0, 0.0); } if(Distance(Cvx2, Cvy2, Cvz2, P2x, P2y, P2z) < 0.18) { SetPlayerHealth(i, 0.0); break; } } } } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PlayerID(pName[],bool:namemode) { for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i)) continue; new name[MAX_PLAYER_NAME]; GetPlayerName(i, name, sizeof(name)); if(namemode==true) { if(strcmp(name, pName, false) == 0) { return i; } } else { if(strfind(name,pName,true,0)) { return i; } } } return -1; }
NiceMoney(amount,sep[]=",") { new str[16],count=-1; format(str,16,"%i",amount); if(strlen(str)<4)return str; for(new i=strlen(str);i>0;i--)//backwards loop ftw! { count++; if(count==3) { strins(str,sep,i); count=0; } } return str; }
PlayerID(pName[],bool:namemode) { for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i)) continue; new name[MAX_PLAYER_NAME]; GetPlayerName(i, name, sizeof(name)); if(strcmp(name, pName, namemode) == 0) { return i; } } return -1; }
Nice, could you post script from these functions, pls
GetPlayerCameraPos(playerid, Cx, Cy, Cz); GetPlayerCameraFrontVector(playerid, Cvx, Cvy, Cvz); @Jay_, thx now I can make to gift flowers with RemovePlayerWeapon , I wanted to make it too, but if there is already this one, I will use this |
Код:
stock NameFromFullRPname(playerid) { new ImeEx[MAX_PLAYER_NAME]; new destinacija[64]; destinacija[0] = 0; GetPlayerName(playerid, ImeEx, sizeof(ImeEx)); if(strfind(ImeEx,"_") != -1) for(new x =0; x < strlen(ImeEx); x++) if(ImeEx[x] == '_') strmid(destinacija, ImeEx, 0, x,sizeof(destinacija)); return destinacija; } Use like this : Код:
new Name[64]; Name = NameFromFullRPname(playerid); printf("Your first name is %s", Name); |
stock GetRolePlayName(playerid, first[24], last[24] = "N/A")
{
new trpn[MAX_PLAYER_NAME];
if(GetPlayerName(playerid,trpn,sizeof(trpn)))
{
new strd = strfind(trpn, "_", false);
if(strd != -1)
{
strmid(first,trpn,0,strd,sizeof(first));
strmid(last,trpn,strd+1,sizeof(trpn),sizeof(last));
return 1;
}
return 0;
}
return 0;
}
new FirstName[MAX_PLAYER_NAME, LastName[Max_PLAYER_NAME]; GetRolePlayName(playerid,FirstName,LastName); //dont need the LastName (optional) printf("First name = %s, and last name = %s", FirstName, LastName);
if(!IsRolePlayName(playerid)) { SendClientMessage(playerid,0xFF0000FF, "You have to have an rp name to play here ('firstname_lastname')!"); Kick(playerid); }
stock IsRolePlayName(playerid, bool:alphaonly = true)
{
new trpn[MAX_PLAYER_NAME];
if(GetPlayerName(playerid,trpn,sizeof(trpn)))
{
new strd = strfind(trpn, "_", false);
if(strfind(trpn,"_",false,strd+1) == -1)
{
if(strd > 0)
{
if(trpn[strd-1] && trpn[strd+1])
{
if(alphaonly)
{
for(new a = 0, l = strlen(trpn); a < l; a++)
{
switch(trpn[a])
{
case '0' .. '9': return 0;
case 'a' .. 'z': continue;
case 'A' .. 'Z': continue;
case '_': continue; // easier than specifying every invalid char
default: return 0;
}
}
}
return 1;
}
}
}
}
return 0;
}
new
Seconds = 1234567,
Minutes,
Hours,
Days;
printf("[USE 1]: Return string from ConvertTime: %s",ConvertTime(Seconds,Minutes,Hours,Days));
printf("[USE 2]: The data from ConvertTime (Vars): %d, %d, %d, %d", Days, Hours, Minutes, Seconds);
//NOTE: Since ConvertTime was used in the first example, the variables already have the data inside.
//ConvertTime has to be used first before you can use the second usage! Its not magic :P.
[23:18:01] [USE 1]: Return string from ConvertTime: 14 days, 6 hours, 56 minutes, and 7 seconds [23:18:01] [USE 2]: The data from ConvertTime (Vars): 14, 6, 56, 7 |
stock ConvertTime(&cts, &ctm=-1,&cth=-1,&ctd=-1,&ctw=-1,&ctmo=-1,&cty=-1)
{
#define PLUR(%0,%1,%2) (%0),((%0) == 1)?((#%1)):((#%2))
#define CTM_cty 31536000
#define CTM_ctmo 2628000
#define CTM_ctw 604800
#define CTM_ctd 86400
#define CTM_cth 3600
#define CTM_ctm 60
#define CT(%0) %0 = cts / CTM_%0; cts %= CTM_%0
new strii[128];
if(cty != -1 && (cts/CTM_cty))
{
CT(cty); CT(ctmo); CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(cty,"year","years"),PLUR(ctmo,"month","months"),PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctmo != -1 && (cts/CTM_ctmo))
{
cty = 0; CT(ctmo); CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(ctmo,"month","months"),PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctw != -1 && (cts/CTM_ctw))
{
cty = 0; ctmo = 0; CT(ctw); CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, %d %s, and %d %s",PLUR(ctw,"week","weeks"),PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctd != -1 && (cts/CTM_ctd))
{
cty = 0; ctmo = 0; ctw = 0; CT(ctd); CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, %d %s, and %d %s",PLUR(ctd,"day","days"),PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(cth != -1 && (cts/CTM_cth))
{
cty = 0; ctmo = 0; ctw = 0; ctd = 0; CT(cth); CT(ctm);
format(strii, sizeof(strii), "%d %s, %d %s, and %d %s",PLUR(cth,"hour","hours"),PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
if(ctm != -1 && (cts/CTM_ctm))
{
cty = 0; ctmo = 0; ctw = 0; ctd = 0; cth = 0; CT(ctm);
format(strii, sizeof(strii), "%d %s, and %d %s",PLUR(ctm,"minute","minutes"),PLUR(cts,"second","seconds"));
return strii;
}
cty = 0; ctmo = 0; ctw = 0; ctd = 0; cth = 0; ctm = 0;
format(strii, sizeof(strii), "%d %s", PLUR(cts,"second","seconds"));
return strii;
}
#define mysql_create_db(%0) mysql_query("CREATE DATABASE %0")
#define mysql_drop_db(%0) mysql_query("DROP DATABASE %0")
#define mysql_auto_increment(%0, %1) mysql_query("ALTER TABLE `%0` AUTO_INCREMENT =%1")
replaceChar(string[128], findchar, replacechar)
{
for(new i; string[i] != 0; ++i)
{
if(string[i] == findchar) string[i] = replacechar;
}
return string;
}
printf("%s", replaceChar("hi i'm just testing my function", ' ', '+'));
hi+i'm+just+testing+my+function
forward SendTeamMessage(color,string[],team);
public SendTeamMessage(color,string[],team)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (GetPlayerTeam(i) == team)
{
SendClientMessage(i, color, string);
}
}
}
return 1;
}
format(string, 128, "Grove team managed to own the Ballas");
SendTeamMessage(COLOR_GREEN, string, Grove);
stock stringContainsIP(const szStr[])
{
new
iDots,
i
;
while(szStr[i] != EOS)
{
if('0' <= szStr[i] <= '9')
{
do
{
if(szStr[i] == '.')
iDots++;
i++;
}
while(('0' <= szStr[i] <= '9') || szStr[i] == '.' || szStr[i] == ':');
}
if(iDots > 2)
return 1;
else
iDots = 0;
i++;
}
return 0;
}
if(stringContainsIP(text))
{
new
szMsg[128]
;
GetPlayerName(playerid, szMsg, MAX_PLAYER_NAME);
format(szMsg, sizeof(szMsg), "%s has been banned due advertising!", szMsg);
SendClientMessageToAll(0xFF0000FF, szMsg);
Ban(playerid);
return 0;
}