Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   1+1=3? (https://forums.graalonline.com/forums/showthread.php?t=56177)

Salaisuus 11-26-2004 03:19 PM

1+1=3?
 
These things are used to pick up and drop an item.

Class melon:
NPC Code:
if (created) {setimg melon.gif;
setshape2 1,1,{22,22};}
if (actionpickup) {
setstring clientr.melon, #v(strtofloat(#s(clientr.melon))+1);
addweapon melon;
destroy;}



Weapon melon:
NPC Code:
 if (actionserverside) { putnpc2 playerx,playery,{join melon;} ;}
//#CLIENTSIDE
if (playerchats&&strequals(#c,drop)){
triggeraction 0,0,serverside,melon,#a;
setstring clientr.melon, #v(strtofloat(#s(clientr.melon))-1);}



Weapon pickup:
NPC Code:
if (weaponfired) {
triggeraction playerx+1.5+vecx(playerdir)*2,
playery+2+vecy(playerdir)*2,pickup,;}



Some compination of these scripts must be causing that
when it(class melon) is picked up you get +2 in the clientr.melon instead of the +1 its supposed to give.
But I cant seem to find out what it is.
Help? :eek:

calum 11-26-2004 06:20 PM

I'm not sure how most of you script could have worked anyway but it works like this after i fixed some things...

melon class...
NPC Code:

if (created)
{
setimg chest.png;
setshape2 1, 1, {22, 22};
}
if (actionpickup) {
setstring clientr.melon, #v(strtofloat(#s(clientr.melon))+1);
addweapon melon;
destroy;
}



melon weapon...
NPC Code:

if (actionserverside)
{
if (strequals(#p(0),melon)){
with(getplayer(#p(1))){
putnpc2 strtofloat(#v(playerx)),strtofloat(#v(playery)),{
join melon;
}
}
}
}
//#CLIENTSIDE

if (playerchats && strequals(#c,drop)){

triggeraction x, y, serverside, melon, melon, #a;

setstring clientr.melon, #v(strtofloat(#s(clientr.melon))-1);
}



pickup weapon...
NPC Code:

//#CLIENTSIDE
if (weaponfired) {
triggeraction playerx + 1.5 + vecx(playerdir)*2, playery + 2 + vecy(playerdir)*2, pickup, ;
}


Tolnaftate2004 11-26-2004 09:05 PM

Its because you can't change a clientr. string clientside. So, you never lose one when you drop it.

Salaisuus 11-27-2004 12:21 AM

Quote:

Its because you can't change a clientr. string clientside. So, you never lose one when you drop it.
Ah yes,
I tough it was working first beacuse I used a npc the check the amount of melons

//#CLIENTSIDE
if (playerchats&&strequals(#c,count melons)){
say2 #s(clientr.melons);}

But because it was client side it aparently gave me some kind of clientside amount of clientr.melon, and i tought they where redusing. odd.
when I checked player atriputes wiht rc it showed a difrent amount.

I got it fixed now, thanks.

xAndrewx 11-27-2004 09:41 AM

I think you needed something to update how many melon's you had. When you pick up a melon add a time out instead of doing one constantly :)

Admins 11-27-2004 04:57 PM

The melon dropper should look like this i guess :

NPC Code:

if (actionserverside) {
quant = strtofloat(#s(clientr.melon));
if (quant>=1) {
setstring clientr.melon,#v(quant-1);
putnpc2 playerx,playery,{join melon;} ;
}
}

//#CLIENTSIDE
if (playerchats && strequals(#c,drop)) {
setplayerprop #c,;
triggeraction 0,0,serverside,melon;
}


xAndrewx 11-27-2004 09:05 PM

Ksi-gs ;)


All times are GMT +2. The time now is 08:48 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.