stock randomColor(Alpha = -1) //iPLEOMAX
return ((random(256) * 16777216) + (random(256) * 65536) + (random(256) * 256) + ((Alpha == -1) ? random(256) : Alpha));
//USAGE:
SendClientMessage(playerid, randomColor(255), "What color is this?");
Anyone else getting an error?
I had to post this from page 314 PM me if the topic needs spamming to get it to the next page (This happened with the Script Request once, someone spammed it and it was fixed) |
colors.pwn(100) : warning 232: output file is written, but with compact encoding disabled
Do you have examples of the colours? Or names for them? If you want loads of colours, you might want to check out this topic:
https://sampforum.blast.hk/showthread.php?tid=319606 (Sorry, another plug for YSI, but if you WILL post things that have been done before... ![]() |
stock
rgbatoabgr(color)
{
new
abgr[1],
rgba[1];
rgba[0] = color;
abgr{3} = rgba{0};
abgr{2} = rgba{1};
abgr{1} = rgba{2};
abgr{0} = rgba{3};
return abgr[0];
}
#define orange ( 0xFF9900AA )
public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp(cmdtext,"/mycommand",true))
{
new Float:X, Float:Y, Float:Z;
new myobject;
GetPlayerPos(playerid, X, Y, Z);
myobject = CreateObject(19371, X, Y, Z+0.5, 0.0, 0.0, 0.0, 300.0);
SetObjectMaterial(myobject, 0, 19341, "egg_texts", "easter_egg01", rgbatoabgr(orange));
//Replaces the texture of our object with the texture of object 19341
return 1;
}
return 0;
}
stock
SendFormattedMessage(playerid,color,msg[],{Float,_}:...)
{
if(!(IsPlayerConnected(playerid))) return 0;
if(!(msg[0]) || (msg[0] == 1) && (msg[1] == 0)) return 0;
else
{
new
pos,
delim = ' ',
num = numargs(),
start = 3,
strr[128]
;
strmid(strr,msg,0,128);
while((pos = strfind(strr,"%",true)) != -1)
{
if(start > num) break;
new
chars,
count = pos+1,
changed_str[128]
;
while((chars = strr[count]) && chars != delim)
{
switch(chars)
{
case 'd','D': // integer
{
new
value = getarg(start,0)
;
strdel(strr,pos,pos+2);
format(changed_str,sizeof(changed_str),"%d",value);
strins(strr,changed_str,pos,128);
start++;
break;
}
case 's','S':
{
new
index,
test
;
for( ; ; )
{
test = getarg(start,index);
if(test == 0) break;
changed_str[index] = test;
index++;
}
strdel(strr,pos,pos+2);
strins(strr,changed_str,pos,128);
start++;
break;
}
case 'f','F':
{
new
value = getarg(start,0)
;
strdel(strr,pos,pos+2);
format(changed_str,sizeof(changed_str),"%0.3f",value);
strins(strr,changed_str,pos,128);
start++;
break;
}
default: // nalezen neznбmэ charakter
{
strdel(strr,pos,pos+2);
break;
}
}
}
}
SendClientMessage(playerid,color,strr);
}
return 1;
}
stock
SendFormattedMessageToAll(color,msg[],{Float,_}:...)
{
if(!(msg[0]) || (msg[0] == 1) && (msg[1] == 0)) return 0;
else
{
new
pos,
delim = ' ',
num = numargs(),
start = 2,
strr[128]
;
strmid(strr,msg,0,128);
while((pos = strfind(strr,"%",true)) != -1)
{
if(start > num) break;
new
chars,
count = pos+1,
changed_str[128]
;
while((chars = strr[count]) && chars != delim)
{
switch(chars)
{
case 'd','D': // integer
{
new
value = getarg(start,0)
;
strdel(strr,pos,pos+2);
format(changed_str,sizeof(changed_str),"%d",value);
strins(strr,changed_str,pos,128);
start++;
break;
}
case 's','S':
{
new
index,
test
;
for( ; ; )
{
test = getarg(start,index);
if(test == 0) break;
changed_str[index] = test;
index++;
}
strdel(strr,pos,pos+2);
strins(strr,changed_str,pos,128);
start++;
break;
}
case 'f','F':
{
new
value = getarg(start,0)
;
strdel(strr,pos,pos+2);
format(changed_str,sizeof(changed_str),"%0.3f",value);
strins(strr,changed_str,pos,128);
start++;
break;
}
default: // nalezen neznбmэ charakter
{
strdel(strr,pos,pos+2);
break;
}
}
}
}
SendClientMessageToAll(color,strr);
}
return 1;
}
#define LOOK 15.0
stock CreatePickupEx(pickupID,pickupStyle,Float:pX,Float:pY,Float:pZ,pVW,text[])
{
CreatePickup(pickupID,pickupStyle,pX,pY,pZ,pVW);
Create3DTextLabel(text,0xFFBF00FF,pX,pY,pZ,LOOK,0,0);
}
CreatePickupEx(1239, 2, 1172.1051, -1321.0652, 15.3980, -1,"Pickup x,y,z: 1172.1051, -1321.0652, 15.3980");
pawn Код:
|
pawn Код:
|
Call_GetPlayerCity(playerid)
{
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
new URL[200] = "geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=";
strcat(URL, ip);
HTTP(playerid, HTTP_GET, URL, "", "MyHttpResponse");
}
forward MyHttpResponse(index, response_code, data[]);
public MyHttpResponse(index, response_code, data[])
{
if(response_code != 200) return;
new start = strfind(data, "\"city\" content=");
start += 16;
strdel(data, 0, start);
new end = strfind(data, "\"");
data[end] = EOS;
print(data); // City here...
}
// Modified version from YSI/y_utils
stock GetIPFromString(const ip[])
{
new
ipv = strval(ip) << 24,
pos = 0;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]) << 16;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]) << 8;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]);
return ipv;
}
1000000 iter = IpToInt - 3215ms 1000000 iter = GetIPFromString - 3333ms
pawn Код:
|
From YSI y_cell:
pawn Код:
|
Yours might be faster, but it's also wrong! The number "255255255255", which is what your version calculates, is different to "255.255.255.255", which is actually the number "0xFFFFFFFF" or "4294967295".
|
stock IpToInt(const szIP[]) {
new
aiBytes[1],
iPos = 0
;
aiBytes{0} = strval(szIP[iPos]);
while(szIP[iPos] != EOS && szIP[iPos++] != '.') {}
aiBytes{1} = strval(szIP[iPos]);
while(szIP[iPos] != EOS && szIP[iPos++] != '.') {}
aiBytes{2} = strval(szIP[iPos]);
while(szIP[iPos] != EOS && szIP[iPos++] != '.') {}
aiBytes{3} = strval(szIP[iPos]);
return aiBytes[0];
}
stock shuffleString(szStr[]) {
for(new i = 0, iLen = strlen(szStr), iRand = 0, iTemp = 0; i < iLen; ++i) {
iRand = i + (random(0) % (iLen - i));
iTemp = szStr[i], szStr[i] = szStr[iRand], szStr[iRand] = iTemp;
}
}
new
szStr[] = "RyDeR`"
;
shuffleString(szStr);
printf("%s", szStr); // Possible output: "yReR`D"
forward Text:TextDrawCreateBox(Float:X, Float:Y, Float:Width, Float:Height, Color);
Text:TextDrawCreateBox(Float:X, Float:Y, Float:Width, Float:Height, Color) //pleo
{
new Text:TD_Box =
TextDrawCreate((X + Width), Y, "_");
TextDrawUseBox(TD_Box, 1);
TextDrawLetterSize(TD_Box, 0.0, (Height/9.6));
TextDrawTextSize(TD_Box, X, 0.0);
TextDrawBoxColor(TD_Box, Color);
return TD_Box;
}
stock ResetObjectMaterial(objectid, materialindex) { SetObjectMaterial(objectid, materialindex, 19341, "invalid", "invalid", 0); } stock ResetPlayerObjectMaterial(playerid, objectid, materialindex) { SetPlayerObjectMaterial(playerid, objectid, materialindex, 19341, "invalid", "invalid", 0); }