
12-19-2011, 03:59 PM
|
|
It's all about cats!
|
 |
Join Date: Sep 2010
Location: France
Posts: 64
|
|
Quote:
Originally Posted by Tolnaftate2004
- You can't modify clientr variables on the client-side. You can perform tests with client variables, but for security reasons, you will want to use clientr variables, which means you will have to modify them on the server-side. If you don't know what I mean, I'm sure someone will post a link here for you. Otherwise, look into triggeraction, triggerclient, and triggerserver if you're not already familiar.
- Because clientr.ammo is unchanged, it is 0. Then, when you check if clientr.ammo < 0 (which, I am assuming should in fact be '>'), that test fails.
- You are mixing GS1 and GS2, which is bad form.
To set the player's chat, use player.chat = "foo".
To set the player's attributes (like #P2), use player.attr[2] = "bar".
To replace a GANI, use replaceani("baz","qux").
- Use = as assignment only and use == as comparison only (see the 3rd line in your code). The engine will fix this for you, but it is bad practice.
- You will only need one //#CLIENTSIDE.
|
Done, except first step.
Now i have that :
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
if (player.chat == "/ammo"){
clientr.ammo += 10;
clientr.capacityammo = 5;
clientr.maxcapacityammmo = 5;
setplayerprop #P2,holst_usp45.png;
replaceani ("walk","holst_gunwalk");
replaceani ("idle","holst_gunidle");
setplayerprop #c,Ammo added;
}
}
function onWeaponFired() {
if (clientr.ammo > 0 && clientr.capacityammo != 0) {
shoot(player.x + vecx(player.dir), player.y + vecy(player.dir), player.z, (playerdir + 1) * pi / 2, NULL, NULL, "holst_bullet", NULL);
setani("holst_gunfire", NULL);
clientr.ammo -= 1;
clientr.capacityammo -= 5;
freezeplayer(0.75);
} else {
player.chat = "No Ammo!";
}
}
if (clientr.ammo == 0) {
player.chat = "No Ammo!";
}
function onActionProjectile() {
player.hearts -= 6;
}
function onKeyPressed( code, key )
{
if ( key == "e" || key == "E" )
{
setani("holst_gunreload", NULL);
}
}
And Gunderak, where i add this code? |
|
|
|