Re: [Request] Hat System
In a sense, it can… But bare with me it is a crude bastard compaired to it’s counterpart.
:HAT NPC EXAMPLE:
[code]if (playerchats && strequals(#c,buy hat 1)) { //Buy Hat
if (strtofloat(#s(server.hat1)) <= 0) {
say2 #b Out of Stock;
} else {
if(playerrupees >= 200) { // Hat Price
setstring client.hat,1; //What ever system you have for adding hats, put it here
setstring server.hat1,#v(strtofloat(#s(server.hat1)) - 1);
} else {
say2 #bNot enough Money;
}
}
}
if (playerenters || playerchats) { //Hat Quantity, Passive Update
if (strtofloat(#s(server.hat1)) <= 0) message Out of Stock!;
else message #s(server.hat1);
}[/code]
Now for the real bastard. (I am aware of all bugs and glitches possible in both, for the most part they cannot be helped without a proper medium.)
:HAT TRADE SYSTEM EXAMPLE:
// "/givehat <hatnumber> <targetaccount>"
// "/accepthat <targetaccount>"
// "/cancelhat" <- Only the Owner may Cancel
if (playerchats) {
tokenize #c;
//Clears Completed Pendings
if(!strequals(#s(pendingtradeid),) && strequals(#s(server.#a#s(pendingtradeid)),) setstring pendingtradeid,;
if (strequals(#t(0),/givehat)) {
if (strequals(#s(pendingtradeid))) {
setstring server.#a#t(2),1; //Add Hat to Trade
setstring client.hat,; //Remove the Hat, Leave it Pending in Trade
setstring pendingtradeid,#t(2); //Remember the Trade ID
} else { //Failsafe of trading only one item at a time
setplayerprop #c,You're already trading to #s(pendingtradeid)! Say "/cancelhat #s(pendingtradeid)" to start a new trade.;
}
} else if (strequals(#t(0),/cancelhat)) {
setstring pendingtradeid,; //Clear Pending Trade
setstring client.hat,1; //Give back the Hat
setstring server.#a#t(1),; //Clear Server Trade
setplayerprop #c,Cancelled Trade with #t(1)!;
} else if (strequals(#t(0),/accepthat)) {
if(strequals(#s(server.#t(1)#a),) {
setplayerprop #c,No Trade Pending from #t(1);
} else {
setplayerprop #c,Accepted Hat#s(server.#t(1)#a) from #t(1)!;
setstring client.hat,#s(server.#t(1)#a); //Give Hat from Trade
setstring server.#t(1)#a,; //Clear Pending
}
}
}
Note that both of these have not been tested in any manner, like most requests they are made on the spot.